aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorlonkaars <loek@pipeframe.xyz>2022-12-20 12:44:12 +0100
committerlonkaars <loek@pipeframe.xyz>2022-12-20 12:44:12 +0100
commit9366676ed5074cf1efee95382cf99728bc3707e7 (patch)
tree5492233830cf37681a3a8bbba82b21e6d107947f
parentda810896f4c249d61f00e9e413d82dad2ad2058e (diff)
ball pixeldata in memory IP core
-rw-r--r--.gitignore1
l---------bouncing-ball/bouncing-ball.srcs/sources_1/bitmap-ball.coe1
l---------bouncing-ball/bouncing-ball.srcs/sources_1/bitmap-ball.vhd1
-rw-r--r--bouncing-ball/bouncing-ball.srcs/sources_1/ip/ball_rom/ball_rom.xci104
-rw-r--r--bouncing-ball/bouncing-ball.srcs/sources_1/new/test.mem0
-rw-r--r--bouncing-ball/bouncing-ball.xpr25
-rw-r--r--src/.gitignore3
-rwxr-xr-xsrc/bitmap-ball.py12
-rw-r--r--src/makefile7
-rw-r--r--src/pixeldata-ball-bottom.vhd27
-rw-r--r--src/pixeldata-ball-top.vhd13
-rw-r--r--src/pixeldata-ball.vhd51
12 files changed, 187 insertions, 58 deletions
diff --git a/.gitignore b/.gitignore
index e73fd1f..550bc61 100644
--- a/.gitignore
+++ b/.gitignore
@@ -5,6 +5,7 @@
*/*.ip_user_files
*/*.runs
*/*.sim
+*/*.gen
# blob
**/*.dcp
diff --git a/bouncing-ball/bouncing-ball.srcs/sources_1/bitmap-ball.coe b/bouncing-ball/bouncing-ball.srcs/sources_1/bitmap-ball.coe
new file mode 120000
index 0000000..fb3b618
--- /dev/null
+++ b/bouncing-ball/bouncing-ball.srcs/sources_1/bitmap-ball.coe
@@ -0,0 +1 @@
+../../../src/bitmap-ball.coe \ No newline at end of file
diff --git a/bouncing-ball/bouncing-ball.srcs/sources_1/bitmap-ball.vhd b/bouncing-ball/bouncing-ball.srcs/sources_1/bitmap-ball.vhd
deleted file mode 120000
index 3631200..0000000
--- a/bouncing-ball/bouncing-ball.srcs/sources_1/bitmap-ball.vhd
+++ /dev/null
@@ -1 +0,0 @@
-../../../src/bitmap-ball.vhd \ No newline at end of file
diff --git a/bouncing-ball/bouncing-ball.srcs/sources_1/ip/ball_rom/ball_rom.xci b/bouncing-ball/bouncing-ball.srcs/sources_1/ip/ball_rom/ball_rom.xci
new file mode 100644
index 0000000..a767ec9
--- /dev/null
+++ b/bouncing-ball/bouncing-ball.srcs/sources_1/ip/ball_rom/ball_rom.xci
@@ -0,0 +1,104 @@
+{
+ "schema": "xilinx.com:schema:json_instance:1.0",
+ "ip_inst": {
+ "xci_name": "ball_rom",
+ "component_reference": "xilinx.com:ip:dist_mem_gen:8.0",
+ "ip_revision": "13",
+ "gen_directory": "../../../../bouncing-ball.gen/sources_1/ip/ball_rom",
+ "parameters": {
+ "component_parameters": {
+ "depth": [ { "value": "128", "value_src": "user", "resolve_type": "user", "format": "long", "usage": "all" } ],
+ "data_width": [ { "value": "12", "value_src": "user", "resolve_type": "user", "format": "long", "usage": "all" } ],
+ "Component_Name": [ { "value": "ball_rom", "resolve_type": "user", "usage": "all" } ],
+ "memory_type": [ { "value": "rom", "value_src": "user", "resolve_type": "user", "usage": "all" } ],
+ "input_options": [ { "value": "non_registered", "resolve_type": "user", "usage": "all" } ],
+ "input_clock_enable": [ { "value": "false", "resolve_type": "user", "format": "bool", "usage": "all" } ],
+ "qualify_we_with_i_ce": [ { "value": "false", "resolve_type": "user", "format": "bool", "usage": "all" } ],
+ "dual_port_address": [ { "value": "non_registered", "resolve_type": "user", "usage": "all" } ],
+ "simple_dual_port_address": [ { "value": "non_registered", "resolve_type": "user", "usage": "all" } ],
+ "output_options": [ { "value": "non_registered", "resolve_type": "user", "usage": "all" } ],
+ "Pipeline_Stages": [ { "value": "0", "resolve_type": "user", "usage": "all" } ],
+ "common_output_clk": [ { "value": "false", "resolve_type": "user", "format": "bool", "usage": "all" } ],
+ "single_port_output_clock_enable": [ { "value": "false", "resolve_type": "user", "format": "bool", "usage": "all" } ],
+ "common_output_ce": [ { "value": "false", "resolve_type": "user", "format": "bool", "usage": "all" } ],
+ "dual_port_output_clock_enable": [ { "value": "false", "resolve_type": "user", "format": "bool", "usage": "all" } ],
+ "simple_dual_port_output_clock_enable": [ { "value": "false", "resolve_type": "user", "format": "bool", "usage": "all" } ],
+ "coefficient_file": [ { "value": "../../bitmap-ball.coe", "value_src": "user", "resolve_type": "user", "usage": "all" } ],
+ "default_data_radix": [ { "value": "16", "resolve_type": "user", "usage": "all" } ],
+ "default_data": [ { "value": "0", "resolve_type": "user", "usage": "all" } ],
+ "reset_qspo": [ { "value": "false", "resolve_type": "user", "format": "bool", "usage": "all" } ],
+ "reset_qdpo": [ { "value": "false", "resolve_type": "user", "format": "bool", "usage": "all" } ],
+ "reset_qsdpo": [ { "value": "false", "resolve_type": "user", "format": "bool", "usage": "all" } ],
+ "sync_reset_qspo": [ { "value": "false", "resolve_type": "user", "format": "bool", "usage": "all" } ],
+ "sync_reset_qdpo": [ { "value": "false", "resolve_type": "user", "format": "bool", "usage": "all" } ],
+ "sync_reset_qsdpo": [ { "value": "false", "resolve_type": "user", "format": "bool", "usage": "all" } ],
+ "ce_overrides": [ { "value": "ce_overrides_sync_controls", "resolve_type": "user", "usage": "all" } ]
+ },
+ "model_parameters": {
+ "C_FAMILY": [ { "value": "artix7", "resolve_type": "generated", "usage": "all" } ],
+ "C_ADDR_WIDTH": [ { "value": "7", "resolve_type": "generated", "format": "long", "usage": "all" } ],
+ "C_DEFAULT_DATA": [ { "value": "0", "resolve_type": "generated", "usage": "all" } ],
+ "C_DEPTH": [ { "value": "128", "resolve_type": "generated", "format": "long", "usage": "all" } ],
+ "C_HAS_CLK": [ { "value": "0", "resolve_type": "generated", "format": "long", "usage": "all" } ],
+ "C_HAS_D": [ { "value": "0", "resolve_type": "generated", "format": "long", "usage": "all" } ],
+ "C_HAS_DPO": [ { "value": "0", "resolve_type": "generated", "format": "long", "usage": "all" } ],
+ "C_HAS_DPRA": [ { "value": "0", "resolve_type": "generated", "format": "long", "usage": "all" } ],
+ "C_HAS_I_CE": [ { "value": "0", "resolve_type": "generated", "format": "long", "usage": "all" } ],
+ "C_HAS_QDPO": [ { "value": "0", "resolve_type": "generated", "format": "long", "usage": "all" } ],
+ "C_HAS_QDPO_CE": [ { "value": "0", "resolve_type": "generated", "format": "long", "usage": "all" } ],
+ "C_HAS_QDPO_CLK": [ { "value": "0", "resolve_type": "generated", "format": "long", "usage": "all" } ],
+ "C_HAS_QDPO_RST": [ { "value": "0", "resolve_type": "generated", "format": "long", "usage": "all" } ],
+ "C_HAS_QDPO_SRST": [ { "value": "0", "resolve_type": "generated", "format": "long", "usage": "all" } ],
+ "C_HAS_QSPO": [ { "value": "0", "resolve_type": "generated", "format": "long", "usage": "all" } ],
+ "C_HAS_QSPO_CE": [ { "value": "0", "resolve_type": "generated", "format": "long", "usage": "all" } ],
+ "C_HAS_QSPO_RST": [ { "value": "0", "resolve_type": "generated", "format": "long", "usage": "all" } ],
+ "C_HAS_QSPO_SRST": [ { "value": "0", "resolve_type": "generated", "format": "long", "usage": "all" } ],
+ "C_HAS_SPO": [ { "value": "1", "resolve_type": "generated", "format": "long", "usage": "all" } ],
+ "C_HAS_WE": [ { "value": "0", "resolve_type": "generated", "format": "long", "usage": "all" } ],
+ "C_MEM_INIT_FILE": [ { "value": "ball_rom.mif", "resolve_type": "generated", "usage": "all" } ],
+ "C_ELABORATION_DIR": [ { "value": "./", "resolve_type": "generated", "usage": "all" } ],
+ "C_MEM_TYPE": [ { "value": "0", "resolve_type": "generated", "format": "long", "usage": "all" } ],
+ "C_PIPELINE_STAGES": [ { "value": "0", "resolve_type": "generated", "format": "long", "usage": "all" } ],
+ "C_QCE_JOINED": [ { "value": "0", "resolve_type": "generated", "format": "long", "usage": "all" } ],
+ "C_QUALIFY_WE": [ { "value": "0", "resolve_type": "generated", "format": "long", "usage": "all" } ],
+ "C_READ_MIF": [ { "value": "1", "resolve_type": "generated", "format": "long", "usage": "all" } ],
+ "C_REG_A_D_INPUTS": [ { "value": "0", "resolve_type": "generated", "format": "long", "usage": "all" } ],
+ "C_REG_DPRA_INPUT": [ { "value": "0", "resolve_type": "generated", "format": "long", "usage": "all" } ],
+ "C_SYNC_ENABLE": [ { "value": "1", "resolve_type": "generated", "format": "long", "usage": "all" } ],
+ "C_WIDTH": [ { "value": "12", "resolve_type": "generated", "format": "long", "usage": "all" } ],
+ "C_PARSER_TYPE": [ { "value": "1", "resolve_type": "generated", "format": "long", "usage": "all" } ]
+ },
+ "project_parameters": {
+ "ARCHITECTURE": [ { "value": "artix7" } ],
+ "BASE_BOARD_PART": [ { "value": "digilentinc.com:basys3:part0:1.2" } ],
+ "BOARD_CONNECTIONS": [ { "value": "" } ],
+ "DEVICE": [ { "value": "xc7a35t" } ],
+ "PACKAGE": [ { "value": "cpg236" } ],
+ "PREFHDL": [ { "value": "VERILOG" } ],
+ "SILICON_REVISION": [ { "value": "" } ],
+ "SIMULATOR_LANGUAGE": [ { "value": "MIXED" } ],
+ "SPEEDGRADE": [ { "value": "-1" } ],
+ "STATIC_POWER": [ { "value": "" } ],
+ "TEMPERATURE_GRADE": [ { "value": "" } ],
+ "USE_RDI_CUSTOMIZATION": [ { "value": "TRUE" } ],
+ "USE_RDI_GENERATION": [ { "value": "TRUE" } ]
+ },
+ "runtime_parameters": {
+ "IPCONTEXT": [ { "value": "IP_Flow" } ],
+ "IPREVISION": [ { "value": "13" } ],
+ "MANAGED": [ { "value": "TRUE" } ],
+ "OUTPUTDIR": [ { "value": "../../../../bouncing-ball.gen/sources_1/ip/ball_rom" } ],
+ "SELECTEDSIMMODEL": [ { "value": "" } ],
+ "SHAREDDIR": [ { "value": "." } ],
+ "SWVERSION": [ { "value": "2022.2" } ],
+ "SYNTHESISFLOW": [ { "value": "GLOBAL" } ]
+ }
+ },
+ "boundary": {
+ "ports": {
+ "a": [ { "direction": "in", "size_left": "6", "size_right": "0", "driver_value": "0" } ],
+ "spo": [ { "direction": "out", "size_left": "11", "size_right": "0" } ]
+ }
+ }
+ }
+} \ No newline at end of file
diff --git a/bouncing-ball/bouncing-ball.srcs/sources_1/new/test.mem b/bouncing-ball/bouncing-ball.srcs/sources_1/new/test.mem
deleted file mode 100644
index e69de29..0000000
--- a/bouncing-ball/bouncing-ball.srcs/sources_1/new/test.mem
+++ /dev/null
diff --git a/bouncing-ball/bouncing-ball.xpr b/bouncing-ball/bouncing-ball.xpr
index 87cca02..7499a79 100644
--- a/bouncing-ball/bouncing-ball.xpr
+++ b/bouncing-ball/bouncing-ball.xpr
@@ -66,13 +66,13 @@
<Option Name="WTVcsLaunchSim" Val="0"/>
<Option Name="WTRivieraLaunchSim" Val="0"/>
<Option Name="WTActivehdlLaunchSim" Val="0"/>
- <Option Name="WTXSimExportSim" Val="0"/>
- <Option Name="WTModelSimExportSim" Val="0"/>
- <Option Name="WTQuestaExportSim" Val="0"/>
+ <Option Name="WTXSimExportSim" Val="2"/>
+ <Option Name="WTModelSimExportSim" Val="2"/>
+ <Option Name="WTQuestaExportSim" Val="2"/>
<Option Name="WTIesExportSim" Val="0"/>
- <Option Name="WTVcsExportSim" Val="0"/>
- <Option Name="WTRivieraExportSim" Val="0"/>
- <Option Name="WTActivehdlExportSim" Val="0"/>
+ <Option Name="WTVcsExportSim" Val="2"/>
+ <Option Name="WTRivieraExportSim" Val="2"/>
+ <Option Name="WTActivehdlExportSim" Val="2"/>
<Option Name="GenerateIPUpgradeLog" Val="TRUE"/>
<Option Name="XSimRadix" Val="hex"/>
<Option Name="XSimTimeUnit" Val="ns"/>
@@ -90,6 +90,13 @@
<FileSets Version="1" Minor="31">
<FileSet Name="sources_1" Type="DesignSrcs" RelSrcDir="$PSRCDIR/sources_1" RelGenDir="$PGENDIR/sources_1">
<Filter Type="Srcs"/>
+ <File Path="$PSRCDIR/sources_1/ip/ball_rom/ball_rom.xci">
+ <FileInfo>
+ <Attr Name="UsedIn" Val="synthesis"/>
+ <Attr Name="UsedIn" Val="implementation"/>
+ <Attr Name="UsedIn" Val="simulation"/>
+ </FileInfo>
+ </File>
<File Path="$PSRCDIR/sources_1/bounce.vhd">
<FileInfo>
<Attr Name="UsedIn" Val="synthesis"/>
@@ -114,6 +121,12 @@
<Attr Name="UsedIn" Val="simulation"/>
</FileInfo>
</File>
+ <File Path="$PSRCDIR/sources_1/bitmap-ball.coe">
+ <FileInfo>
+ <Attr Name="UsedIn" Val="synthesis"/>
+ <Attr Name="UsedIn" Val="simulation"/>
+ </FileInfo>
+ </File>
<Config>
<Option Name="DesignMode" Val="RTL"/>
<Option Name="TopModule" Val="main"/>
diff --git a/src/.gitignore b/src/.gitignore
index d830ccc..e23e341 100644
--- a/src/.gitignore
+++ b/src/.gitignore
@@ -1,3 +1,2 @@
-pixeldata-ball.vhd
-bitmap-ball.vhd
+bitmap-ball.coe
diff --git a/src/bitmap-ball.py b/src/bitmap-ball.py
index 4d5be0c..25b7fd3 100755
--- a/src/bitmap-ball.py
+++ b/src/bitmap-ball.py
@@ -21,10 +21,10 @@ def pixeldata():
if __name__ == "__main__":
# get array of 12-bit pixels
pixels = pixeldata()
- # declare rom_t as array with size len(pixels) and word width of 12 bits
- print(f"type rom_t is array (0 to {len(pixels) - 1}) of std_logic_vector(11 downto 0);")
- # format pixel value as x"rgb" (12-bit hexadecimal with padding)
- formatted_pixels = [f"x\"{hex(c)[2:].zfill(3)}\"" for c in pixels]
- # print constant bitmap_ball
- print(f"constant bitmap_ball: rom_t := ({', '.join(formatted_pixels)});")
+ # coe file header
+ print("memory_initialization_radix=16;\nmemory_initialization_vector=", end='')
+ # format pixel value as 12-bit hexadecimal with padding seperated by comma and space
+ formatted_pixels = ','.join([f"{hex(c)[2:].zfill(3)}" for c in pixels])
+ print(f"{formatted_pixels};")
+
diff --git a/src/makefile b/src/makefile
index 5dff86d..8ecc8f2 100644
--- a/src/makefile
+++ b/src/makefile
@@ -1,6 +1,7 @@
-pixeldata-ball.vhd: pixeldata-ball-top.vhd bitmap-ball.vhd pixeldata-ball-bottom.vhd
- cat $^ > $@
+.PHONY: clean
-bitmap-ball.vhd: ball.png
+bitmap-ball.coe: ball.png
python3 bitmap-ball.py $< > $@
+clean:
+ $(RM) bitmap-ball.coe
diff --git a/src/pixeldata-ball-bottom.vhd b/src/pixeldata-ball-bottom.vhd
deleted file mode 100644
index 966af41..0000000
--- a/src/pixeldata-ball-bottom.vhd
+++ /dev/null
@@ -1,27 +0,0 @@
- component bounce
- port (
- clk, reset: in std_logic;
- x, y: out std_logic_vector(9 downto 0));
- end component;
- signal sx, sy: std_logic_vector(9 downto 0); -- square x and y
- signal pixel_index: integer;
-begin
- bounce_pos: component bounce
- port map (
- reset => reset,
- clk => bounce_clk,
- x => sx,
- y => sy);
- process(pixel_clk, sx, sy)
- begin
- if rising_edge(pixel_clk) then
- if (x >= sx) and (x < sx + 10) and (y >= sy) and (y < sy + 10) then
- -- draw 10x10 pixel box in white
- rgb <= bitmap_ball(to_integer(unsigned(x - sx)) + to_integer(unsigned(y - sy)) * 10);
- else
- -- blue background
- rgb <= x"00f";
- end if;
- end if;
- end process;
-end Behavioral;
diff --git a/src/pixeldata-ball-top.vhd b/src/pixeldata-ball-top.vhd
deleted file mode 100644
index 77ef000..0000000
--- a/src/pixeldata-ball-top.vhd
+++ /dev/null
@@ -1,13 +0,0 @@
-library ieee;
-use ieee.std_logic_1164.all;
-use ieee.std_logic_unsigned.all;
-use ieee.numeric_std.all;
-
-entity pixeldata is
- port (
- pixel_clk, bounce_clk, reset: in std_logic;
- x, y: in std_logic_vector(9 downto 0);
- rgb: out std_logic_vector(11 downto 0));
-end pixeldata;
-
-architecture Behavioral of pixeldata is
diff --git a/src/pixeldata-ball.vhd b/src/pixeldata-ball.vhd
new file mode 100644
index 0000000..4690241
--- /dev/null
+++ b/src/pixeldata-ball.vhd
@@ -0,0 +1,51 @@
+library ieee;
+use ieee.std_logic_1164.all;
+use ieee.std_logic_unsigned.all;
+use ieee.numeric_std.all;
+
+entity pixeldata is
+ port (
+ pixel_clk, bounce_clk, reset: in std_logic;
+ x, y: in std_logic_vector(9 downto 0);
+ rgb: out std_logic_vector(11 downto 0));
+end pixeldata;
+
+architecture Behavioral of pixeldata is
+ component bounce
+ port (
+ clk, reset: in std_logic;
+ x, y: out std_logic_vector(9 downto 0));
+ end component;
+ component ball_rom
+ port (
+ a: in std_logic_vector(6 downto 0);
+ spo: out std_logic_vector(11 downto 0));
+ end component;
+ signal sx, sy: std_logic_vector(9 downto 0); -- square x and y
+ signal bitmap_idx: std_logic_vector(6 downto 0);
+ signal bitmap_out: std_logic_vector(11 downto 0);
+begin
+ bounce_pos: component bounce
+ port map (
+ reset => reset,
+ clk => bounce_clk,
+ x => sx,
+ y => sy);
+ bitmap_lookup: component ball_rom
+ port map (
+ a => bitmap_idx,
+ spo => bitmap_out);
+ process(pixel_clk)
+ begin
+ if rising_edge(pixel_clk) then
+ if (x >= sx) and (x < sx + 10) and (y >= sy) and (y < sy + 10) then
+ -- draw ball
+ bitmap_idx <= std_logic_vector(resize(unsigned(y - sy) + unsigned(y - sy) * 10, bitmap_idx'length));
+ rgb <= bitmap_out;
+ else
+ -- blue background
+ rgb <= x"00f";
+ end if;
+ end if;
+ end process;
+end Behavioral;