📄 microrom.vhd
字号:
library IEEE;use STD.textio.all;use IEEE.std_logic_1164.all;use work.dp32_types.all;entity microrom is generic ( Tac_read : Time := 4 ns; load_file_name : string := "microcode.txt" ); port ( a : in bus_bit_32 bus; d : out bit_96 );end microrom;architecture file_loaded of microrom isbegin mem_behavior : process type memory_array is array (natural range 0 to 128198 ) of bit_96; variable mc : memory_array; procedure load is file binary_file : text is in load_file_name; variable L : line; variable ch : character; variable addr : bit_32; variable data : bit_96; procedure read_2 ( L : inout line; n1 : out bit_32; n2 : out bit_96 ) is variable t : natural :=0; variable ta : bit_vector (3 downto 0); variable tb : bit; begin for i in 1 to 8 loop --*********errors near here cause my bad format in microcode.txt ch:=L(i); if '0' <= ch and ch <= '9' then t := character'pos(ch) - character'pos('0'); elsif 'A' <= ch and ch <= 'F' then t := character'pos(ch) - character'pos('A') + 10; elsif 'a' <= ch and ch <= 'f' then t := character'pos(ch) - character'pos('a') + 10; end if; natural_to_bits(t,ta); n1 ( (-i+9)*4-1 downto (-i+8)*4 ) := ta; end loop; for i in 30 to 30+95 loop ch:=L(i); if '0' = ch then tb:='0'; else tb:='1'; end if; n2 (i-30 ) := tb; end loop; end read_2; begin while not endfile(binary_file) loop readline(binary_file, L); if(L(1)='!') then else read_2(L, addr,data);-- assert false report vector_to_string(addr) severity warning; mc(bits_to_uint(addr)) := data; end if; end loop; end load; procedure do_read is begin --assert false report vector_to_string(a) severity warning; d <= mc(bits_to_uint(a)) after Tac_read; --assert false report vector_to_string(mc(bits_to_uint(a))) severity warning; end do_read; variable bit_temp : bit; begin load; -- read binary memory image into memory array loop wait for 1 ns; do_read; end loop; end process mem_behavior;end file_loaded;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -