added vhdl template for new BlockRam, see #232

This commit is contained in:
hneemann 2019-01-24 17:02:27 +01:00
parent 0e001268ac
commit c0b139741e
5 changed files with 58 additions and 1 deletions

View File

@ -0,0 +1,49 @@
LIBRARY ieee;
USE ieee.std_logic_1164.all;
USE ieee.numeric_std.all;
<?
entityName := "BlockRam_D"+elem.Bits+"A"+elem.AddrBits;
maskBits := elem.Bits / 8;
?>
entity <?=entityName?> is
port (
D: out std_logic_vector (<?=elem.Bits-1?> downto 0);
A: in std_logic_vector (<?=elem.AddrBits-1?> downto 0);
Din: in std_logic_vector (<?=elem.Bits-1?> downto 0);
str: in <?
if (maskBits=1) {
print("std_logic;");
} else {
print("std_logic_vector ("+(maskBits-1)+" downto 0);");
} ?>
C: in std_logic );
end <?=entityName?>;
architecture Behavioral of <?=entityName?> is
type memoryType is array(0 to <?=(1<<elem.AddrBits)-1?>) of std_logic_vector(<?=elem.Bits-1?> downto 0);
signal memory : memoryType;
signal rData : std_logic_vector (<?=elem.Bits-1?> downto 0) := (others => '0');
begin
process ( C )
begin
if rising_edge(C) then
rData <= memory(to_integer(unsigned(A)));
<? if (maskBits=1) { ?>
if str='1' then
memory(to_integer(unsigned(A))) <= Din;
end if;
<? } else {
for (i:=0;i<maskBits;i++) {
?>
if str(<?=i?>)='1' then
memory(to_integer(unsigned(A)))(<?=i*8+7?> downto <?=i*8?>) <= Din(<?=i*8+7?> downto <?=i*8?>);
end if;
<?
}
} ?>
end if;
end process;
D <= rData;
end Behavioral;

View File

@ -47,7 +47,7 @@ public class VHDLSimulatorTest extends TestCase {
File examples = new File(Resources.getRoot(), "/dig/test/vhdl");
try {
int tested = new FileScanner(this::checkVHDLExport).noOutput().scan(examples);
assertEquals(33, tested);
assertEquals(36, tested);
assertEquals(tested+2, testBenches);
} catch (FileScanner.SkipAllException e) {
// if ghdl is not installed its also ok

View File

@ -78,6 +78,7 @@
<dataString>C A Din mask D
# no write at all, mask is zero
C 0 0 0b1111 x
C 0 0xffffffff 0b0000 x
C 0 0 0b0000 0
@ -97,6 +98,7 @@ C 0 0 0b0000 0xffffffff
# write 16 bit words
C 1 0 0b1111 x
C 1 0xffff 0b0011 x
C 1 0 0b0000 0xffff
@ -108,6 +110,7 @@ C 1 0 0b0000 0xffaaaaff
# write 32 bit words
C 2 0 0b1111 x
C 2 0xffffffff 0b1111 x
C 2 0 0b0000 0xffffffff

View File

@ -78,6 +78,7 @@
<dataString>C A Din mask D
# no write at all, mask is zero
C 0 0 0b11111111 x
C 0 0xffffffffffffffff 0b00000000 x
C 0 0 0b00000000 0
@ -109,6 +110,8 @@ C 0 0 0b00000000 0xffffffffffffffff
# write 32 bit words
C 1 0 0b11111111 x
C 1 0xffffffff 0b00001111 x
C 1 0 0b00000000 0xffffffff

View File

@ -74,6 +74,7 @@
<dataString>C A Din mask D
# no write at all, mask is zero
C 0 0 1 x
C 0 0xff 0 x
C 0 0 0 0
@ -82,6 +83,7 @@ C 0 0 0 0
C 0 0xff 1 x
C 1 0xf0 1 x
C 2 0 1 x
C 2 0 0 0
0 0 0 0 0
0 1 0 0 0