Last active
January 14, 2022 08:07
-
-
Save mkj/00f8d39c95ec9e173b3534b686a7ad2a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Generated by Yosys 0.13+3 (git sha1 61324cf55, clang 10.0.0-4ubuntu1 -fPIC -Os) | |
autoidx 17 | |
module \testram | |
wire width 2048 $auto$ghdl.cc:805:import_module$1 | |
wire width 8 $auto$ghdl.cc:805:import_module$10 | |
wire width 2048 $auto$ghdl.cc:805:import_module$11 | |
wire width 8 $auto$ghdl.cc:805:import_module$12 | |
wire width 2048 $auto$ghdl.cc:805:import_module$13 | |
wire width 8 $auto$ghdl.cc:805:import_module$14 | |
wire width 2048 $auto$ghdl.cc:805:import_module$15 | |
wire width 8 $auto$ghdl.cc:805:import_module$16 | |
wire width 8 $auto$ghdl.cc:805:import_module$2 | |
wire width 2048 $auto$ghdl.cc:805:import_module$3 | |
wire width 8 $auto$ghdl.cc:805:import_module$4 | |
wire width 2048 $auto$ghdl.cc:805:import_module$5 | |
wire width 8 $auto$ghdl.cc:805:import_module$6 | |
wire width 2048 $auto$ghdl.cc:805:import_module$7 | |
wire width 8 $auto$ghdl.cc:805:import_module$8 | |
wire width 2048 $auto$ghdl.cc:805:import_module$9 | |
wire input 1 \clk | |
wire width 8 input 3 \rd_addr | |
wire width 64 output 7 \rd_data | |
wire input 2 \rd_en | |
wire width 8 input 5 \wr_addr | |
wire width 64 input 6 \wr_data | |
wire width 8 input 4 \wr_sel | |
memory width 8 size 256 \ram:1 | |
memory width 8 size 256 \ram:2 | |
memory width 8 size 256 \ram:3 | |
memory width 8 size 256 \ram:4 | |
memory width 8 size 256 \ram:5 | |
memory width 8 size 256 \ram:6 | |
memory width 8 size 256 \ram:7 | |
memory width 8 size 256 \ram:8 | |
cell $memrd_v2 \ram:1$r0 | |
parameter \ABITS 8 | |
parameter \ARST_VALUE 8'x | |
parameter \CE_OVER_SRST 1'1 | |
parameter \CLK_ENABLE 1'1 | |
parameter \CLK_POLARITY 1'1 | |
parameter \COLLISION_X_MASK 1'0 | |
parameter \INIT_VALUE 8'x | |
parameter \MEMID "\\ram:1" | |
parameter \SRST_VALUE 8'x | |
parameter \TRANSPARENCY_MASK 1'0 | |
parameter \WIDTH 8 | |
connect \ADDR \rd_addr | |
connect \ARST 1'0 | |
connect \CLK \clk | |
connect \DATA $auto$ghdl.cc:805:import_module$2 | |
connect \EN \rd_en | |
connect \SRST 1'0 | |
end | |
cell $memwr_v2 \ram:1$w0 | |
parameter \ABITS 8 | |
parameter \CLK_ENABLE 1'1 | |
parameter \CLK_POLARITY 1'1 | |
parameter \MEMID "\\ram:1" | |
parameter \PORTID 0 | |
parameter \PRIORITY_MASK 1'0 | |
parameter \WIDTH 8 | |
connect \ADDR \wr_addr | |
connect \CLK \clk | |
connect \DATA \wr_data [7:0] | |
connect \EN { \wr_sel [0] \wr_sel [0] \wr_sel [0] \wr_sel [0] \wr_sel [0] \wr_sel [0] \wr_sel [0] \wr_sel [0] } | |
end | |
cell $memrd_v2 \ram:2$r0 | |
parameter \ABITS 8 | |
parameter \ARST_VALUE 8'x | |
parameter \CE_OVER_SRST 1'1 | |
parameter \CLK_ENABLE 1'1 | |
parameter \CLK_POLARITY 1'1 | |
parameter \COLLISION_X_MASK 1'0 | |
parameter \INIT_VALUE 8'x | |
parameter \MEMID "\\ram:2" | |
parameter \SRST_VALUE 8'x | |
parameter \TRANSPARENCY_MASK 1'0 | |
parameter \WIDTH 8 | |
connect \ADDR \rd_addr | |
connect \ARST 1'0 | |
connect \CLK \clk | |
connect \DATA $auto$ghdl.cc:805:import_module$4 | |
connect \EN \rd_en | |
connect \SRST 1'0 | |
end | |
cell $memwr_v2 \ram:2$w0 | |
parameter \ABITS 8 | |
parameter \CLK_ENABLE 1'1 | |
parameter \CLK_POLARITY 1'1 | |
parameter \MEMID "\\ram:2" | |
parameter \PORTID 0 | |
parameter \PRIORITY_MASK 1'0 | |
parameter \WIDTH 8 | |
connect \ADDR \wr_addr | |
connect \CLK \clk | |
connect \DATA \wr_data [15:8] | |
connect \EN { \wr_sel [1] \wr_sel [1] \wr_sel [1] \wr_sel [1] \wr_sel [1] \wr_sel [1] \wr_sel [1] \wr_sel [1] } | |
end | |
cell $memrd_v2 \ram:3$r0 | |
parameter \ABITS 8 | |
parameter \ARST_VALUE 8'x | |
parameter \CE_OVER_SRST 1'1 | |
parameter \CLK_ENABLE 1'1 | |
parameter \CLK_POLARITY 1'1 | |
parameter \COLLISION_X_MASK 1'0 | |
parameter \INIT_VALUE 8'x | |
parameter \MEMID "\\ram:3" | |
parameter \SRST_VALUE 8'x | |
parameter \TRANSPARENCY_MASK 1'0 | |
parameter \WIDTH 8 | |
connect \ADDR \rd_addr | |
connect \ARST 1'0 | |
connect \CLK \clk | |
connect \DATA $auto$ghdl.cc:805:import_module$6 | |
connect \EN \rd_en | |
connect \SRST 1'0 | |
end | |
cell $memwr_v2 \ram:3$w0 | |
parameter \ABITS 8 | |
parameter \CLK_ENABLE 1'1 | |
parameter \CLK_POLARITY 1'1 | |
parameter \MEMID "\\ram:3" | |
parameter \PORTID 0 | |
parameter \PRIORITY_MASK 1'0 | |
parameter \WIDTH 8 | |
connect \ADDR \wr_addr | |
connect \CLK \clk | |
connect \DATA \wr_data [23:16] | |
connect \EN { \wr_sel [2] \wr_sel [2] \wr_sel [2] \wr_sel [2] \wr_sel [2] \wr_sel [2] \wr_sel [2] \wr_sel [2] } | |
end | |
cell $memrd_v2 \ram:4$r0 | |
parameter \ABITS 8 | |
parameter \ARST_VALUE 8'x | |
parameter \CE_OVER_SRST 1'1 | |
parameter \CLK_ENABLE 1'1 | |
parameter \CLK_POLARITY 1'1 | |
parameter \COLLISION_X_MASK 1'0 | |
parameter \INIT_VALUE 8'x | |
parameter \MEMID "\\ram:4" | |
parameter \SRST_VALUE 8'x | |
parameter \TRANSPARENCY_MASK 1'0 | |
parameter \WIDTH 8 | |
connect \ADDR \rd_addr | |
connect \ARST 1'0 | |
connect \CLK \clk | |
connect \DATA $auto$ghdl.cc:805:import_module$8 | |
connect \EN \rd_en | |
connect \SRST 1'0 | |
end | |
cell $memwr_v2 \ram:4$w0 | |
parameter \ABITS 8 | |
parameter \CLK_ENABLE 1'1 | |
parameter \CLK_POLARITY 1'1 | |
parameter \MEMID "\\ram:4" | |
parameter \PORTID 0 | |
parameter \PRIORITY_MASK 1'0 | |
parameter \WIDTH 8 | |
connect \ADDR \wr_addr | |
connect \CLK \clk | |
connect \DATA \wr_data [31:24] | |
connect \EN { \wr_sel [3] \wr_sel [3] \wr_sel [3] \wr_sel [3] \wr_sel [3] \wr_sel [3] \wr_sel [3] \wr_sel [3] } | |
end | |
cell $memrd_v2 \ram:5$r0 | |
parameter \ABITS 8 | |
parameter \ARST_VALUE 8'x | |
parameter \CE_OVER_SRST 1'1 | |
parameter \CLK_ENABLE 1'1 | |
parameter \CLK_POLARITY 1'1 | |
parameter \COLLISION_X_MASK 1'0 | |
parameter \INIT_VALUE 8'x | |
parameter \MEMID "\\ram:5" | |
parameter \SRST_VALUE 8'x | |
parameter \TRANSPARENCY_MASK 1'0 | |
parameter \WIDTH 8 | |
connect \ADDR \rd_addr | |
connect \ARST 1'0 | |
connect \CLK \clk | |
connect \DATA $auto$ghdl.cc:805:import_module$10 | |
connect \EN \rd_en | |
connect \SRST 1'0 | |
end | |
cell $memwr_v2 \ram:5$w0 | |
parameter \ABITS 8 | |
parameter \CLK_ENABLE 1'1 | |
parameter \CLK_POLARITY 1'1 | |
parameter \MEMID "\\ram:5" | |
parameter \PORTID 0 | |
parameter \PRIORITY_MASK 1'0 | |
parameter \WIDTH 8 | |
connect \ADDR \wr_addr | |
connect \CLK \clk | |
connect \DATA \wr_data [39:32] | |
connect \EN { \wr_sel [4] \wr_sel [4] \wr_sel [4] \wr_sel [4] \wr_sel [4] \wr_sel [4] \wr_sel [4] \wr_sel [4] } | |
end | |
cell $memrd_v2 \ram:6$r0 | |
parameter \ABITS 8 | |
parameter \ARST_VALUE 8'x | |
parameter \CE_OVER_SRST 1'1 | |
parameter \CLK_ENABLE 1'1 | |
parameter \CLK_POLARITY 1'1 | |
parameter \COLLISION_X_MASK 1'0 | |
parameter \INIT_VALUE 8'x | |
parameter \MEMID "\\ram:6" | |
parameter \SRST_VALUE 8'x | |
parameter \TRANSPARENCY_MASK 1'0 | |
parameter \WIDTH 8 | |
connect \ADDR \rd_addr | |
connect \ARST 1'0 | |
connect \CLK \clk | |
connect \DATA $auto$ghdl.cc:805:import_module$12 | |
connect \EN \rd_en | |
connect \SRST 1'0 | |
end | |
cell $memwr_v2 \ram:6$w0 | |
parameter \ABITS 8 | |
parameter \CLK_ENABLE 1'1 | |
parameter \CLK_POLARITY 1'1 | |
parameter \MEMID "\\ram:6" | |
parameter \PORTID 0 | |
parameter \PRIORITY_MASK 1'0 | |
parameter \WIDTH 8 | |
connect \ADDR \wr_addr | |
connect \CLK \clk | |
connect \DATA \wr_data [47:40] | |
connect \EN { \wr_sel [5] \wr_sel [5] \wr_sel [5] \wr_sel [5] \wr_sel [5] \wr_sel [5] \wr_sel [5] \wr_sel [5] } | |
end | |
cell $memrd_v2 \ram:7$r0 | |
parameter \ABITS 8 | |
parameter \ARST_VALUE 8'x | |
parameter \CE_OVER_SRST 1'1 | |
parameter \CLK_ENABLE 1'1 | |
parameter \CLK_POLARITY 1'1 | |
parameter \COLLISION_X_MASK 1'0 | |
parameter \INIT_VALUE 8'x | |
parameter \MEMID "\\ram:7" | |
parameter \SRST_VALUE 8'x | |
parameter \TRANSPARENCY_MASK 1'0 | |
parameter \WIDTH 8 | |
connect \ADDR \rd_addr | |
connect \ARST 1'0 | |
connect \CLK \clk | |
connect \DATA $auto$ghdl.cc:805:import_module$14 | |
connect \EN \rd_en | |
connect \SRST 1'0 | |
end | |
cell $memwr_v2 \ram:7$w0 | |
parameter \ABITS 8 | |
parameter \CLK_ENABLE 1'1 | |
parameter \CLK_POLARITY 1'1 | |
parameter \MEMID "\\ram:7" | |
parameter \PORTID 0 | |
parameter \PRIORITY_MASK 1'0 | |
parameter \WIDTH 8 | |
connect \ADDR \wr_addr | |
connect \CLK \clk | |
connect \DATA \wr_data [55:48] | |
connect \EN { \wr_sel [6] \wr_sel [6] \wr_sel [6] \wr_sel [6] \wr_sel [6] \wr_sel [6] \wr_sel [6] \wr_sel [6] } | |
end | |
cell $memrd_v2 \ram:8$r0 | |
parameter \ABITS 8 | |
parameter \ARST_VALUE 8'x | |
parameter \CE_OVER_SRST 1'1 | |
parameter \CLK_ENABLE 1'1 | |
parameter \CLK_POLARITY 1'1 | |
parameter \COLLISION_X_MASK 1'0 | |
parameter \INIT_VALUE 8'x | |
parameter \MEMID "\\ram:8" | |
parameter \SRST_VALUE 8'x | |
parameter \TRANSPARENCY_MASK 1'0 | |
parameter \WIDTH 8 | |
connect \ADDR \rd_addr | |
connect \ARST 1'0 | |
connect \CLK \clk | |
connect \DATA $auto$ghdl.cc:805:import_module$16 | |
connect \EN \rd_en | |
connect \SRST 1'0 | |
end | |
cell $memwr_v2 \ram:8$w0 | |
parameter \ABITS 8 | |
parameter \CLK_ENABLE 1'1 | |
parameter \CLK_POLARITY 1'1 | |
parameter \MEMID "\\ram:8" | |
parameter \PORTID 0 | |
parameter \PRIORITY_MASK 1'0 | |
parameter \WIDTH 8 | |
connect \ADDR \wr_addr | |
connect \CLK \clk | |
connect \DATA \wr_data [63:56] | |
connect \EN { \wr_sel [7] \wr_sel [7] \wr_sel [7] \wr_sel [7] \wr_sel [7] \wr_sel [7] \wr_sel [7] \wr_sel [7] } | |
end | |
connect \rd_data { $auto$ghdl.cc:805:import_module$16 $auto$ghdl.cc:805:import_module$14 $auto$ghdl.cc:805:import_module$12 $auto$ghdl.cc:805:import_module$10 $auto$ghdl.cc:805:import_module$8 $auto$ghdl.cc:805:import_module$6 $auto$ghdl.cc:805:import_module$4 $auto$ghdl.cc:805:import_module$2 } | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SOURCES = testram.vhdl | |
YOSYS ?= yosys | |
GHDLPLUGIN ?= $(shell ($(YOSYS) -H | grep -q ghdl) || echo -m ghdl) | |
all: testram.v | |
testram.v: $(SOURCES) Makefile | |
$(YOSYS) $(GHDLPLUGIN) -p "ghdl $(SOURCES) -e testram; write_verilog $@" | |
testram-synth.rtlil: $(SOURCES) Makefile | |
$(YOSYS) $(GHDLPLUGIN) -p "ghdl $(SOURCES) -e testram; write_rtlil input-$@; synth_ecp5 ; write_rtlil $@" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library ieee; | |
use ieee.std_logic_1164.all; | |
use ieee.numeric_std.all; | |
use ieee.math_real.all; | |
entity testram is | |
generic( | |
ROW_BITS : integer := 8; | |
WIDTH : integer := 64 | |
); | |
port( | |
clk : in std_logic; | |
rd_en : in std_logic; | |
rd_addr : in std_logic_vector(ROW_BITS - 1 downto 0); | |
rd_data : out std_logic_vector(WIDTH - 1 downto 0); | |
wr_sel : in std_logic_vector(WIDTH/8 - 1 downto 0); | |
wr_addr : in std_logic_vector(ROW_BITS - 1 downto 0); | |
wr_data : in std_logic_vector(WIDTH - 1 downto 0) | |
); | |
end testram; | |
architecture rtl of testram is | |
constant SIZE : integer := 2**ROW_BITS; | |
type ram_type is array (0 to SIZE - 1) of std_logic_vector(WIDTH - 1 downto 0); | |
signal ram : ram_type; | |
--attribute syn_ramstyle : string; | |
--attribute syn_ramstyle of ram : signal is "block_ram"; | |
begin | |
process(clk) | |
variable lbit : integer range 0 to WIDTH - 1; | |
variable mbit : integer range 0 to WIDTH - 1; | |
variable widx : integer range 0 to SIZE - 1; | |
constant sel0 : std_logic_vector(WIDTH/8 - 1 downto 0) | |
:= (others => '0'); | |
begin | |
if rising_edge(clk) then | |
widx := to_integer(unsigned(wr_addr)); | |
for i in 0 to WIDTH/8-1 loop | |
lbit := i * 8; | |
mbit := lbit + 7; | |
if wr_sel(i) = '1' then | |
ram(widx)(mbit downto lbit) <= wr_data(mbit downto lbit); | |
end if; | |
end loop; | |
if rd_en = '1' then | |
rd_data <= ram(to_integer(unsigned(rd_addr))); | |
end if; | |
end if; | |
end process; | |
end; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment