vertigo_vhdl 0.8.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/bin/vertigo +7 -0
- data/lib/vertigo.rb +4 -0
- data/lib/vertigo/ast.rb +87 -0
- data/lib/vertigo/ast_vertigo_rkgen.rb +607 -0
- data/lib/vertigo/code.rb +57 -0
- data/lib/vertigo/compiler.rb +61 -0
- data/lib/vertigo/generic_lexer.rb +61 -0
- data/lib/vertigo/generic_parser.rb +44 -0
- data/lib/vertigo/indent.rb +20 -0
- data/lib/vertigo/lexer.rb +172 -0
- data/lib/vertigo/parser.rb +1458 -0
- data/lib/vertigo/pretty_printer.rb +749 -0
- data/lib/vertigo/runner.rb +115 -0
- data/lib/vertigo/tb_generator.rb +81 -0
- data/lib/vertigo/template.tb.vhd +72 -0
- data/lib/vertigo/token.rb +67 -0
- data/lib/vertigo/version.rb +3 -0
- data/lib/vertigo/vertigo.rkg +354 -0
- data/lib/vertigo/visitor_vertigo_rkgen.rb +447 -0
- data/tests/ghdl_tests/fsm.vhd +98 -0
- data/tests/ghdl_tests/fsm_synth.vhd +248 -0
- data/tests/ghdl_tests/test_fsm.vhd +162 -0
- data/tests/parser_tests/else.vhd +64 -0
- data/tests/parser_tests/test_MUST_fail.vhd +1 -0
- data/tests/parser_tests/test_accelerator.vhd +160 -0
- data/tests/parser_tests/test_accelerator_pp.vhd +144 -0
- data/tests/parser_tests/test_aggregate.vhd +17 -0
- data/tests/parser_tests/test_aggregate_pp.vhd +15 -0
- data/tests/parser_tests/test_archi_1.vhd +45 -0
- data/tests/parser_tests/test_archi_1_pp.vhd +41 -0
- data/tests/parser_tests/test_array_array_00.vhd +25 -0
- data/tests/parser_tests/test_array_array_00_pp.vhd +25 -0
- data/tests/parser_tests/test_array_urange.vhd +25 -0
- data/tests/parser_tests/test_array_urange_pp.vhd +25 -0
- data/tests/parser_tests/test_chu-1.vhd +80 -0
- data/tests/parser_tests/test_chu-1_pp.vhd +104 -0
- data/tests/parser_tests/test_concat.vhd +11 -0
- data/tests/parser_tests/test_concat_pp.vhd +14 -0
- data/tests/parser_tests/test_counter.vhd +35 -0
- data/tests/parser_tests/test_counter_pp.vhd +35 -0
- data/tests/parser_tests/test_de2.vhd +358 -0
- data/tests/parser_tests/test_de2_pp.vhd +274 -0
- data/tests/parser_tests/test_encode.vhd +2679 -0
- data/tests/parser_tests/test_encode_pp.vhd +2549 -0
- data/tests/parser_tests/test_fsm.vhd +162 -0
- data/tests/parser_tests/test_fsm_pp.vhd +125 -0
- data/tests/parser_tests/test_fsm_synth.vhd +248 -0
- data/tests/parser_tests/test_fsm_synth_pp.vhd +197 -0
- data/tests/parser_tests/test_function-01.vhd +33 -0
- data/tests/parser_tests/test_function-01_pp.vhd +18 -0
- data/tests/parser_tests/test_lfsr.vhd +75 -0
- data/tests/parser_tests/test_lfsr_pp.vhd +44 -0
- data/tests/parser_tests/test_microwatt_cache_ram.vhd +1 -0
- data/tests/parser_tests/test_microwatt_cache_ram_pp.vhd +68 -0
- data/tests/parser_tests/test_microwatt_common.vhd +1 -0
- data/tests/parser_tests/test_microwatt_common_pp.vhd +336 -0
- data/tests/parser_tests/test_microwatt_control.vhd +1 -0
- data/tests/parser_tests/test_microwatt_control_pp.vhd +187 -0
- data/tests/parser_tests/test_microwatt_core.vhd +1 -0
- data/tests/parser_tests/test_microwatt_core_debug.vhd +1 -0
- data/tests/parser_tests/test_microwatt_core_debug_pp.vhd +104 -0
- data/tests/parser_tests/test_microwatt_core_pp.vhd +231 -0
- data/tests/parser_tests/test_microwatt_core_tb.vhd +1 -0
- data/tests/parser_tests/test_microwatt_core_tb_pp.vhd +43 -0
- data/tests/parser_tests/test_microwatt_countzero.vhd +1 -0
- data/tests/parser_tests/test_microwatt_countzero_pp.vhd +120 -0
- data/tests/parser_tests/test_microwatt_countzero_tb.vhd +1 -0
- data/tests/parser_tests/test_microwatt_countzero_tb_pp.vhd +70 -0
- data/tests/parser_tests/test_microwatt_cr_file.vhd +1 -0
- data/tests/parser_tests/test_microwatt_cr_file_pp.vhd +74 -0
- data/tests/parser_tests/test_microwatt_cr_hazard.vhd +1 -0
- data/tests/parser_tests/test_microwatt_cr_hazard_pp.vhd +51 -0
- data/tests/parser_tests/test_microwatt_crhelpers.vhd +1 -0
- data/tests/parser_tests/test_microwatt_crhelpers_pp.vhd +48 -0
- data/tests/parser_tests/test_microwatt_dcache.vhd +1 -0
- data/tests/parser_tests/test_microwatt_dcache_pp.vhd +481 -0
- data/tests/parser_tests/test_microwatt_dcache_tb.vhd +1 -0
- data/tests/parser_tests/test_microwatt_dcache_tb_pp.vhd +98 -0
- data/tests/parser_tests/test_microwatt_decode1.vhd +1 -0
- data/tests/parser_tests/test_microwatt_decode1_pp.vhd +138 -0
- data/tests/parser_tests/test_microwatt_decode2.vhd +1 -0
- data/tests/parser_tests/test_microwatt_decode2_pp.vhd +300 -0
- data/tests/parser_tests/test_microwatt_decode_types.vhd +1 -0
- data/tests/parser_tests/test_microwatt_decode_types_pp.vhd +67 -0
- data/tests/parser_tests/test_microwatt_divider.vhd +1 -0
- data/tests/parser_tests/test_microwatt_divider_pp.vhd +132 -0
- data/tests/parser_tests/test_microwatt_divider_tb.vhd +1 -0
- data/tests/parser_tests/test_microwatt_divider_tb_pp.vhd +95 -0
- data/tests/parser_tests/test_microwatt_dmi_dtm_dummy.vhd +1 -0
- data/tests/parser_tests/test_microwatt_dmi_dtm_dummy_pp.vhd +29 -0
- data/tests/parser_tests/test_microwatt_dmi_dtm_tb.vhd +1 -0
- data/tests/parser_tests/test_microwatt_dmi_dtm_tb_pp.vhd +197 -0
- data/tests/parser_tests/test_microwatt_dmi_dtm_xilinx.vhd +1 -0
- data/tests/parser_tests/test_microwatt_dmi_dtm_xilinx_pp.vhd +139 -0
- data/tests/parser_tests/test_microwatt_execute1.vhd +1 -0
- data/tests/parser_tests/test_microwatt_execute1_pp.vhd +689 -0
- data/tests/parser_tests/test_microwatt_fetch1.vhd +1 -0
- data/tests/parser_tests/test_microwatt_fetch1_pp.vhd +88 -0
- data/tests/parser_tests/test_microwatt_fetch2.vhd +1 -0
- data/tests/parser_tests/test_microwatt_fetch2_pp.vhd +79 -0
- data/tests/parser_tests/test_microwatt_glibc_random.vhd +1 -0
- data/tests/parser_tests/test_microwatt_glibc_random_helpers.vhd +1 -0
- data/tests/parser_tests/test_microwatt_glibc_random_helpers_pp.vhd +25 -0
- data/tests/parser_tests/test_microwatt_glibc_random_pp.vhd +41 -0
- data/tests/parser_tests/test_microwatt_gpr_hazard.vhd +1 -0
- data/tests/parser_tests/test_microwatt_gpr_hazard_pp.vhd +68 -0
- data/tests/parser_tests/test_microwatt_helpers.vhd +1 -0
- data/tests/parser_tests/test_microwatt_helpers_pp.vhd +153 -0
- data/tests/parser_tests/test_microwatt_icache.vhd +1 -0
- data/tests/parser_tests/test_microwatt_icache_pp.vhd +337 -0
- data/tests/parser_tests/test_microwatt_icache_tb.vhd +1 -0
- data/tests/parser_tests/test_microwatt_icache_tb_pp.vhd +104 -0
- data/tests/parser_tests/test_microwatt_insn_helpers.vhd +1 -0
- data/tests/parser_tests/test_microwatt_insn_helpers_pp.vhd +208 -0
- data/tests/parser_tests/test_microwatt_loadstore1.vhd +1 -0
- data/tests/parser_tests/test_microwatt_loadstore1_pp.vhd +222 -0
- data/tests/parser_tests/test_microwatt_logical.vhd +1 -0
- data/tests/parser_tests/test_microwatt_logical_pp.vhd +87 -0
- data/tests/parser_tests/test_microwatt_multiply.vhd +1 -0
- data/tests/parser_tests/test_microwatt_multiply_pp.vhd +84 -0
- data/tests/parser_tests/test_microwatt_multiply_tb.vhd +1 -0
- data/tests/parser_tests/test_microwatt_multiply_tb_pp.vhd +75 -0
- data/tests/parser_tests/test_microwatt_plru.vhd +1 -0
- data/tests/parser_tests/test_microwatt_plru_pp.vhd +46 -0
- data/tests/parser_tests/test_microwatt_plru_tb.vhd +1 -0
- data/tests/parser_tests/test_microwatt_plru_tb_pp.vhd +93 -0
- data/tests/parser_tests/test_microwatt_ppc_fx_insns.vhd +1 -0
- data/tests/parser_tests/test_microwatt_ppc_fx_insns_pp.vhd +665 -0
- data/tests/parser_tests/test_microwatt_register_file.vhd +1 -0
- data/tests/parser_tests/test_microwatt_register_file_pp.vhd +86 -0
- data/tests/parser_tests/test_microwatt_rotator.vhd +1 -0
- data/tests/parser_tests/test_microwatt_rotator_pp.vhd +149 -0
- data/tests/parser_tests/test_microwatt_rotator_tb.vhd +1 -0
- data/tests/parser_tests/test_microwatt_rotator_tb_pp.vhd +134 -0
- data/tests/parser_tests/test_microwatt_sim_bram.vhd +1 -0
- data/tests/parser_tests/test_microwatt_sim_bram_helpers.vhd +1 -0
- data/tests/parser_tests/test_microwatt_sim_bram_helpers_pp.vhd +52 -0
- data/tests/parser_tests/test_microwatt_sim_bram_pp.vhd +53 -0
- data/tests/parser_tests/test_microwatt_sim_console.vhd +1 -0
- data/tests/parser_tests/test_microwatt_sim_console_pp.vhd +43 -0
- data/tests/parser_tests/test_microwatt_sim_jtag.vhd +1 -0
- data/tests/parser_tests/test_microwatt_sim_jtag_pp.vhd +64 -0
- data/tests/parser_tests/test_microwatt_sim_jtag_socket.vhd +1 -0
- data/tests/parser_tests/test_microwatt_sim_jtag_socket_pp.vhd +36 -0
- data/tests/parser_tests/test_microwatt_sim_uart.vhd +1 -0
- data/tests/parser_tests/test_microwatt_sim_uart_pp.vhd +90 -0
- data/tests/parser_tests/test_microwatt_soc.vhd +1 -0
- data/tests/parser_tests/test_microwatt_soc_pp.vhd +195 -0
- data/tests/parser_tests/test_microwatt_utils.vhd +1 -0
- data/tests/parser_tests/test_microwatt_utils_pp.vhd +39 -0
- data/tests/parser_tests/test_microwatt_wishbone_arbiter.vhd +1 -0
- data/tests/parser_tests/test_microwatt_wishbone_arbiter_pp.vhd +54 -0
- data/tests/parser_tests/test_microwatt_wishbone_bram_tb.vhd +1 -0
- data/tests/parser_tests/test_microwatt_wishbone_bram_tb_pp.vhd +157 -0
- data/tests/parser_tests/test_microwatt_wishbone_bram_wrapper.vhd +1 -0
- data/tests/parser_tests/test_microwatt_wishbone_bram_wrapper_pp.vhd +62 -0
- data/tests/parser_tests/test_microwatt_wishbone_debug_master.vhd +1 -0
- data/tests/parser_tests/test_microwatt_wishbone_debug_master_pp.vhd +124 -0
- data/tests/parser_tests/test_microwatt_wishbone_types.vhd +1 -0
- data/tests/parser_tests/test_microwatt_wishbone_types_pp.vhd +38 -0
- data/tests/parser_tests/test_microwatt_writeback.vhd +1 -0
- data/tests/parser_tests/test_microwatt_writeback_pp.vhd +87 -0
- data/tests/parser_tests/test_package-1.vhd +68 -0
- data/tests/parser_tests/test_package-1_pp.vhd +53 -0
- data/tests/parser_tests/test_precedence.vhd +13 -0
- data/tests/parser_tests/test_precedence_pp.vhd +16 -0
- data/tests/parser_tests/test_selected_sig.vhd +14 -0
- data/tests/parser_tests/test_selected_sig_pp.vhd +10 -0
- data/tests/parser_tests/test_slice.vhd +15 -0
- data/tests/parser_tests/test_slice_pp.vhd +16 -0
- data/tests/parser_tests/test_tb-00.vhd +94 -0
- data/tests/parser_tests/test_tb-00_pp.vhd +71 -0
- data/tests/parser_tests/test_type_decl_02.vhd +9 -0
- data/tests/parser_tests/test_type_decl_02_pp.vhd +11 -0
- data/tests/parser_tests/test_use.vhd +7 -0
- data/tests/parser_tests/test_use_pp.vhd +10 -0
- data/tests/parser_tests/test_while_1.vhd +38 -0
- data/tests/parser_tests/test_while_1_pp.vhd +26 -0
- data/tests/parser_tests/test_with-00.vhd +21 -0
- data/tests/parser_tests/test_with-00_pp.vhd +12 -0
- data/tests/tb_gen_tests/test_accelerator.vhd +160 -0
- metadata +224 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
../microwatt/register_file.vhdl
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
-- generated by Vertigo VHDL tool
|
|
2
|
+
library ieee;
|
|
3
|
+
use ieee.std_logic_1164.all;
|
|
4
|
+
use ieee.numeric_std.all;
|
|
5
|
+
library work;
|
|
6
|
+
use work.common.all;
|
|
7
|
+
|
|
8
|
+
entity register_file is
|
|
9
|
+
generic(
|
|
10
|
+
sim : booleanfalse := false);
|
|
11
|
+
port(
|
|
12
|
+
clk : in std_logic;
|
|
13
|
+
d_in : in decode2toregisterfiletype;
|
|
14
|
+
d_out : out registerfiletodecode2type;
|
|
15
|
+
w_in : in writebacktoregisterfiletype;
|
|
16
|
+
sim_dump : in std_ulogic;
|
|
17
|
+
sim_dump_done : out std_ulogic);
|
|
18
|
+
end entity register_file;
|
|
19
|
+
|
|
20
|
+
architecture behaviour of register_file is
|
|
21
|
+
|
|
22
|
+
type regfile is array(range 0 to 63) of std_ulogic_vector(63 downto 0);
|
|
23
|
+
signal registers : regfile := (others => (others => '0'));
|
|
24
|
+
begin
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
register_write_0 : process(clk)
|
|
28
|
+
begin
|
|
29
|
+
if rising_edge(clk) then
|
|
30
|
+
if w_in.write_enable = '1' then
|
|
31
|
+
assert (is_x(w_in.write_data)) and (is_x(w_in.write_reg));
|
|
32
|
+
if w_in.write_reg(5) = '0' then
|
|
33
|
+
report "writing gpr " & to_hstring(w_in.write_reg) & " " & to_hstring(w_in.write_data);
|
|
34
|
+
else
|
|
35
|
+
report "writing gspr " & to_hstring(w_in.write_reg) & " " & to_hstring(w_in.write_data);
|
|
36
|
+
end if;
|
|
37
|
+
registers(to_integer(unsigned(w_in.write_reg))) <= w_in.write_data;
|
|
38
|
+
end if;
|
|
39
|
+
end if;
|
|
40
|
+
end process;
|
|
41
|
+
|
|
42
|
+
register_read_0 : process(all)
|
|
43
|
+
begin
|
|
44
|
+
if d_in.read1_enable = '1' then
|
|
45
|
+
report "reading gpr " & to_hstring(d_in.read1_reg) & " " & to_hstring(registers(to_integer(unsigned(d_in.read1_reg))));
|
|
46
|
+
end if;
|
|
47
|
+
if d_in.read2_enable = '1' then
|
|
48
|
+
report "reading gpr " & to_hstring(d_in.read2_reg) & " " & to_hstring(registers(to_integer(unsigned(d_in.read2_reg))));
|
|
49
|
+
end if;
|
|
50
|
+
if d_in.read3_enable = '1' then
|
|
51
|
+
report "reading gpr " & to_hstring(d_in.read3_reg) & " " & to_hstring(registers(to_integer(unsigned(d_in.read3_reg))));
|
|
52
|
+
end if;
|
|
53
|
+
d_out.read1_data <= registers(to_integer(unsigned(d_in.read1_reg)));
|
|
54
|
+
d_out.read2_data <= registers(to_integer(unsigned(d_in.read2_reg)));
|
|
55
|
+
d_out.read3_data <= registers(to_integer(unsigned(gpr_to_gspr(d_in.read3_reg))));
|
|
56
|
+
if w_in.write_enable = '1' then
|
|
57
|
+
if d_in.read1_reg = w_in.write_reg then
|
|
58
|
+
d_out.read1_data <= w_in.write_data;
|
|
59
|
+
end if;
|
|
60
|
+
if d_in.read2_reg = w_in.write_reg then
|
|
61
|
+
d_out.read2_data <= w_in.write_data;
|
|
62
|
+
end if;
|
|
63
|
+
if gpr_to_gspr(d_in.read3_reg) = w_in.write_reg then
|
|
64
|
+
d_out.read3_data <= w_in.write_data;
|
|
65
|
+
end if;
|
|
66
|
+
end if;
|
|
67
|
+
end process;
|
|
68
|
+
if sim generate
|
|
69
|
+
|
|
70
|
+
dump_registers : process(all)
|
|
71
|
+
begin
|
|
72
|
+
if sim_dump = '1' then
|
|
73
|
+
;
|
|
74
|
+
report "lr " & to_hstring(registers(to_integer(unsigned(fast_spr_num(spr_lr)))));
|
|
75
|
+
report "ctr " & to_hstring(registers(to_integer(unsigned(fast_spr_num(spr_ctr)))));
|
|
76
|
+
report "xer " & to_hstring(registers(to_integer(unsigned(fast_spr_num(spr_xer)))));
|
|
77
|
+
sim_dump_done <= '1';
|
|
78
|
+
else
|
|
79
|
+
sim_dump_done <= '0';
|
|
80
|
+
end if;
|
|
81
|
+
end process;
|
|
82
|
+
end generate;
|
|
83
|
+
if sim generate
|
|
84
|
+
sim_dump_done <= '0';
|
|
85
|
+
end generate;
|
|
86
|
+
end behaviour;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
../microwatt/rotator.vhdl
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
-- generated by Vertigo VHDL tool
|
|
2
|
+
library ieee;
|
|
3
|
+
use ieee.std_logic_1164.all;
|
|
4
|
+
use ieee.numeric_std.all;
|
|
5
|
+
library work;
|
|
6
|
+
use work.common.all;
|
|
7
|
+
|
|
8
|
+
entity rotator is
|
|
9
|
+
port(
|
|
10
|
+
rs : in std_ulogic_vector(63 downto 0);
|
|
11
|
+
ra : in std_ulogic_vector(63 downto 0);
|
|
12
|
+
shift : in std_ulogic_vector(6 downto 0);
|
|
13
|
+
insn : in std_ulogic_vector(31 downto 0);
|
|
14
|
+
is_32bit : in std_ulogic;
|
|
15
|
+
right_shift : in std_ulogic;
|
|
16
|
+
arith : in std_ulogic;
|
|
17
|
+
clear_left : in std_ulogic;
|
|
18
|
+
clear_right : in std_ulogic;
|
|
19
|
+
result : out std_ulogic_vector(63 downto 0);
|
|
20
|
+
carry_out : out std_ulogic);
|
|
21
|
+
end entity rotator;
|
|
22
|
+
|
|
23
|
+
architecture behaviour of rotator is
|
|
24
|
+
signal repl32 : std_ulogic_vector(63 downto 0);
|
|
25
|
+
signal rot_count : std_ulogic_vector(5 downto 0);
|
|
26
|
+
signal rot1 : std_ulogic_vector(63 downto 0);
|
|
27
|
+
signal rot2 : std_ulogic_vector(63 downto 0);
|
|
28
|
+
signal rot : std_ulogic_vector(63 downto 0);
|
|
29
|
+
signal sh : std_ulogic_vector(6 downto 0);
|
|
30
|
+
signal mb : std_ulogic_vector(6 downto 0);
|
|
31
|
+
signal me : std_ulogic_vector(6 downto 0);
|
|
32
|
+
signal mr : std_ulogic_vector(63 downto 0);
|
|
33
|
+
signal ml : std_ulogic_vector(63 downto 0);
|
|
34
|
+
signal output_mode : std_ulogic_vector(1 downto 0);
|
|
35
|
+
|
|
36
|
+
function right_mask(mask_begin : std_ulogic_vector(6 downto 0)) return std_ulogic_vector is
|
|
37
|
+
variable ret : std_ulogic_vector(63 downto 0);
|
|
38
|
+
begin
|
|
39
|
+
ret := (others => '0');
|
|
40
|
+
return ret;
|
|
41
|
+
end function right_mask;
|
|
42
|
+
|
|
43
|
+
function left_mask(mask_end : std_ulogic_vector(6 downto 0)) return std_ulogic_vector is
|
|
44
|
+
variable ret : std_ulogic_vector(63 downto 0);
|
|
45
|
+
begin
|
|
46
|
+
ret := (others => '0');
|
|
47
|
+
if mask_end(6) = '0' then
|
|
48
|
+
;
|
|
49
|
+
end if;
|
|
50
|
+
return ret;
|
|
51
|
+
end function left_mask;
|
|
52
|
+
begin
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
rotator_0 : process(all)
|
|
56
|
+
begin
|
|
57
|
+
if is_32bit = '1' then
|
|
58
|
+
repl32 <= rs(31 downto 0) & rs(31 downto 0);
|
|
59
|
+
else
|
|
60
|
+
repl32 <= rs;
|
|
61
|
+
end if;
|
|
62
|
+
if right_shift = '1' then
|
|
63
|
+
rot_count <= std_ulogic_vector(signed(shift(5 downto 0)));
|
|
64
|
+
else
|
|
65
|
+
rot_count <= shift(5 downto 0);
|
|
66
|
+
end if;
|
|
67
|
+
case rot_count(1 downto 0) is
|
|
68
|
+
when "00" =>
|
|
69
|
+
rot1 <= repl32;
|
|
70
|
+
when "01" =>
|
|
71
|
+
rot1 <= repl32(62 downto 0) & repl32(63);
|
|
72
|
+
when "10" =>
|
|
73
|
+
rot1 <= repl32(61 downto 0) & repl32(63 downto 62);
|
|
74
|
+
when others =>
|
|
75
|
+
rot1 <= repl32(60 downto 0) & repl32(63 downto 61);
|
|
76
|
+
end case;
|
|
77
|
+
case rot_count(3 downto 2) is
|
|
78
|
+
when "00" =>
|
|
79
|
+
rot2 <= rot1;
|
|
80
|
+
when "01" =>
|
|
81
|
+
rot2 <= rot1(59 downto 0) & rot1(63 downto 60);
|
|
82
|
+
when "10" =>
|
|
83
|
+
rot2 <= rot1(55 downto 0) & rot1(63 downto 56);
|
|
84
|
+
when others =>
|
|
85
|
+
rot2 <= rot1(51 downto 0) & rot1(63 downto 52);
|
|
86
|
+
end case;
|
|
87
|
+
case rot_count(5 downto 4) is
|
|
88
|
+
when "00" =>
|
|
89
|
+
rot <= rot2;
|
|
90
|
+
when "01" =>
|
|
91
|
+
rot <= rot2(47 downto 0) & rot2(63 downto 48);
|
|
92
|
+
when "10" =>
|
|
93
|
+
rot <= rot2(31 downto 0) & rot2(63 downto 32);
|
|
94
|
+
when others =>
|
|
95
|
+
rot <= rot2(15 downto 0) & rot2(63 downto 16);
|
|
96
|
+
end case;
|
|
97
|
+
sh <= (shift(6) and is_32bit) & shift(5 downto 0);
|
|
98
|
+
if clear_left = '1' then
|
|
99
|
+
if is_32bit = '1' then
|
|
100
|
+
mb <= "01" & insn(10 downto 6);
|
|
101
|
+
else
|
|
102
|
+
mb <= "0" & insn(5) & insn(10 downto 6);
|
|
103
|
+
end if;
|
|
104
|
+
elsif right_shift = '1' then
|
|
105
|
+
if is_32bit = '1' then
|
|
106
|
+
mb <= sh(5) & sh(5) & sh(4 downto 0);
|
|
107
|
+
else
|
|
108
|
+
mb <= sh;
|
|
109
|
+
end if;
|
|
110
|
+
else
|
|
111
|
+
mb <= ('0' & is_32bit & "00000");
|
|
112
|
+
end if;
|
|
113
|
+
if clear_right = '1' and is_32bit = '1' then
|
|
114
|
+
me <= "01" & insn(5 downto 1);
|
|
115
|
+
elsif clear_right = '1' and clear_left = '0' then
|
|
116
|
+
me <= "0" & insn(5) & insn(10 downto 6);
|
|
117
|
+
else
|
|
118
|
+
me <= sh(6) & sh(5 downto 0);
|
|
119
|
+
end if;
|
|
120
|
+
mr <= right_mask(mb);
|
|
121
|
+
ml <= left_mask(me);
|
|
122
|
+
if (clear_left = '1' and clear_right = '0') or right_shift = '1' then
|
|
123
|
+
output_mode(1) <= '1';
|
|
124
|
+
output_mode(0) <= arith and repl32(63);
|
|
125
|
+
else
|
|
126
|
+
output_mode(1) <= '0';
|
|
127
|
+
if clear_right = '1' and unsigned(mb(5 downto 0)) > unsigned(me(5 downto 0)) then
|
|
128
|
+
output_mode(0) <= '1';
|
|
129
|
+
else
|
|
130
|
+
output_mode(0) <= '0';
|
|
131
|
+
end if;
|
|
132
|
+
end if;
|
|
133
|
+
case output_mode is
|
|
134
|
+
when "00" =>
|
|
135
|
+
result <= (rot and (mr and ml)) or (ra and (mr and ml));
|
|
136
|
+
when "01" =>
|
|
137
|
+
result <= (rot and (mr or ml)) or (ra and (mr or ml));
|
|
138
|
+
when "10" =>
|
|
139
|
+
result <= rot and mr;
|
|
140
|
+
when others =>
|
|
141
|
+
result <= rot or mr;
|
|
142
|
+
end case;
|
|
143
|
+
if output_mode = "11" then
|
|
144
|
+
carry_out <= or(rs and ml);
|
|
145
|
+
else
|
|
146
|
+
carry_out <= '0';
|
|
147
|
+
end if;
|
|
148
|
+
end process;
|
|
149
|
+
end behaviour;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
../microwatt/rotator_tb.vhdl
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
-- generated by Vertigo VHDL tool
|
|
2
|
+
library ieee;
|
|
3
|
+
use ieee.std_logic_1164.all;
|
|
4
|
+
use ieee.numeric_std.all;
|
|
5
|
+
library work;
|
|
6
|
+
use work.common.all;
|
|
7
|
+
use work.glibc_random.all;
|
|
8
|
+
use work.ppc_fx_insns.all;
|
|
9
|
+
use work.insn_helpers.all;
|
|
10
|
+
|
|
11
|
+
entity rotator_tb is
|
|
12
|
+
end entity rotator_tb;
|
|
13
|
+
|
|
14
|
+
architecture behave of rotator_tb is
|
|
15
|
+
constant clk_period : time := 10 ns;
|
|
16
|
+
signal ra : std_ulogic_vector(63 downto 0);
|
|
17
|
+
signal rs : std_ulogic_vector(63 downto 0);
|
|
18
|
+
signal shift : std_ulogic_vector(6 downto 0) := (others => '0');
|
|
19
|
+
signal insn : std_ulogic_vector(31 downto 0) := (others => '0');
|
|
20
|
+
signal is_32bit : std_ulogic;
|
|
21
|
+
signal right_shift : std_ulogic;
|
|
22
|
+
signal arith : std_ulogic;
|
|
23
|
+
signal clear_left : std_ulogic;
|
|
24
|
+
signal clear_right : std_ulogic := '0';
|
|
25
|
+
signal result : std_ulogic_vector(63 downto 0);
|
|
26
|
+
signal carry_out : std_ulogic;
|
|
27
|
+
begin
|
|
28
|
+
|
|
29
|
+
rotator_0 : entity work.rotator
|
|
30
|
+
port map(
|
|
31
|
+
rs => rs,
|
|
32
|
+
ra => ra,
|
|
33
|
+
shift => shift,
|
|
34
|
+
insn => insn,
|
|
35
|
+
is_32bit => is_32bit,
|
|
36
|
+
right_shift => right_shift,
|
|
37
|
+
arith => arith,
|
|
38
|
+
clear_left => clear_left,
|
|
39
|
+
clear_right => clear_right,
|
|
40
|
+
result => result,
|
|
41
|
+
carry_out => carry_out);
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
stim_process : process
|
|
45
|
+
variable behave_ra : std_ulogic_vector(63 downto 0);
|
|
46
|
+
variable behave_ca_ra : std_ulogic_vector(64 downto 0);
|
|
47
|
+
begin
|
|
48
|
+
report "test rlw[i]nm";
|
|
49
|
+
ra <= (others => '0');
|
|
50
|
+
is_32bit <= '1';
|
|
51
|
+
right_shift <= '0';
|
|
52
|
+
arith <= '0';
|
|
53
|
+
clear_left <= '1';
|
|
54
|
+
clear_right <= '1';
|
|
55
|
+
report "test rlwimi";
|
|
56
|
+
is_32bit <= '1';
|
|
57
|
+
right_shift <= '0';
|
|
58
|
+
arith <= '0';
|
|
59
|
+
clear_left <= '1';
|
|
60
|
+
clear_right <= '1';
|
|
61
|
+
report "test rld[i]cl";
|
|
62
|
+
ra <= (others => '0');
|
|
63
|
+
is_32bit <= '0';
|
|
64
|
+
right_shift <= '0';
|
|
65
|
+
arith <= '0';
|
|
66
|
+
clear_left <= '1';
|
|
67
|
+
clear_right <= '0';
|
|
68
|
+
report "test rld[i]cr";
|
|
69
|
+
ra <= (others => '0');
|
|
70
|
+
is_32bit <= '0';
|
|
71
|
+
right_shift <= '0';
|
|
72
|
+
arith <= '0';
|
|
73
|
+
clear_left <= '0';
|
|
74
|
+
clear_right <= '1';
|
|
75
|
+
report "test rldic";
|
|
76
|
+
ra <= (others => '0');
|
|
77
|
+
is_32bit <= '0';
|
|
78
|
+
right_shift <= '0';
|
|
79
|
+
arith <= '0';
|
|
80
|
+
clear_left <= '1';
|
|
81
|
+
clear_right <= '1';
|
|
82
|
+
report "test rldimi";
|
|
83
|
+
is_32bit <= '0';
|
|
84
|
+
right_shift <= '0';
|
|
85
|
+
arith <= '0';
|
|
86
|
+
clear_left <= '1';
|
|
87
|
+
clear_right <= '1';
|
|
88
|
+
report "test slw";
|
|
89
|
+
ra <= (others => '0');
|
|
90
|
+
is_32bit <= '1';
|
|
91
|
+
right_shift <= '0';
|
|
92
|
+
arith <= '0';
|
|
93
|
+
clear_left <= '0';
|
|
94
|
+
clear_right <= '0';
|
|
95
|
+
report "test sld";
|
|
96
|
+
ra <= (others => '0');
|
|
97
|
+
is_32bit <= '0';
|
|
98
|
+
right_shift <= '0';
|
|
99
|
+
arith <= '0';
|
|
100
|
+
clear_left <= '0';
|
|
101
|
+
clear_right <= '0';
|
|
102
|
+
report "test srw";
|
|
103
|
+
ra <= (others => '0');
|
|
104
|
+
is_32bit <= '1';
|
|
105
|
+
right_shift <= '1';
|
|
106
|
+
arith <= '0';
|
|
107
|
+
clear_left <= '0';
|
|
108
|
+
clear_right <= '0';
|
|
109
|
+
report "test srd";
|
|
110
|
+
ra <= (others => '0');
|
|
111
|
+
is_32bit <= '0';
|
|
112
|
+
right_shift <= '1';
|
|
113
|
+
arith <= '0';
|
|
114
|
+
clear_left <= '0';
|
|
115
|
+
clear_right <= '0';
|
|
116
|
+
report "test sraw[i]";
|
|
117
|
+
ra <= (others => '0');
|
|
118
|
+
is_32bit <= '1';
|
|
119
|
+
right_shift <= '1';
|
|
120
|
+
arith <= '1';
|
|
121
|
+
clear_left <= '0';
|
|
122
|
+
clear_right <= '0';
|
|
123
|
+
report "test srad[i]";
|
|
124
|
+
ra <= (others => '0');
|
|
125
|
+
is_32bit <= '0';
|
|
126
|
+
right_shift <= '1';
|
|
127
|
+
arith <= '1';
|
|
128
|
+
clear_left <= '0';
|
|
129
|
+
clear_right <= '0';
|
|
130
|
+
assert false
|
|
131
|
+
report "end of test" severity failure;
|
|
132
|
+
wait ;
|
|
133
|
+
end process;
|
|
134
|
+
end behave;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
../microwatt/sim_bram.vhdl
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
../microwatt/sim_bram_helpers.vhdl
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
-- generated by Vertigo VHDL tool
|
|
2
|
+
library ieee;
|
|
3
|
+
use ieee.std_logic_1164.all;
|
|
4
|
+
|
|
5
|
+
package sim_bram_helpers is
|
|
6
|
+
function behavioural_initialize(filename : string;size : integer) return integer
|
|
7
|
+
attribute foreign of behavioural_initialize : function is "vhpidirect behavioural_initialize";
|
|
8
|
+
|
|
9
|
+
procedure behavioural_read(
|
|
10
|
+
val : out std_ulogic_vector(63 downto 0);
|
|
11
|
+
addr : std_ulogic_vector(63 downto 0);
|
|
12
|
+
length : integer;
|
|
13
|
+
identifier : integer);
|
|
14
|
+
attribute foreign of behavioural_read : procedure is "vhpidirect behavioural_read";
|
|
15
|
+
|
|
16
|
+
procedure behavioural_write(
|
|
17
|
+
val : std_ulogic_vector(63 downto 0);
|
|
18
|
+
addr : std_ulogic_vector(63 downto 0);
|
|
19
|
+
length : integer;
|
|
20
|
+
identifier : integer);
|
|
21
|
+
attribute foreign of behavioural_write : procedure is "vhpidirect behavioural_write";
|
|
22
|
+
|
|
23
|
+
end sim_bram_helpers;
|
|
24
|
+
|
|
25
|
+
package body sim_bram_helpers is
|
|
26
|
+
|
|
27
|
+
function behavioural_initialize(filename : string;size : integer) return integer is
|
|
28
|
+
begin
|
|
29
|
+
assert false
|
|
30
|
+
report "vhpi" severity failure;
|
|
31
|
+
end function behavioural_initialize;
|
|
32
|
+
|
|
33
|
+
procedure behavioural_read(
|
|
34
|
+
val : out std_ulogic_vector(63 downto 0);
|
|
35
|
+
addr : std_ulogic_vector(63 downto 0);
|
|
36
|
+
length : integer;
|
|
37
|
+
identifier : integer) is
|
|
38
|
+
begin
|
|
39
|
+
assert false
|
|
40
|
+
report "vhpi" severity failure;
|
|
41
|
+
end behavioural_read;
|
|
42
|
+
|
|
43
|
+
procedure behavioural_write(
|
|
44
|
+
val : std_ulogic_vector(63 downto 0);
|
|
45
|
+
addr : std_ulogic_vector(63 downto 0);
|
|
46
|
+
length : integer;
|
|
47
|
+
identifier : integer) is
|
|
48
|
+
begin
|
|
49
|
+
assert false
|
|
50
|
+
report "vhpi" severity failure;
|
|
51
|
+
end behavioural_write;
|
|
52
|
+
end sim_bram_helpers;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
-- generated by Vertigo VHDL tool
|
|
2
|
+
library ieee;
|
|
3
|
+
use ieee.std_logic_1164.all;
|
|
4
|
+
use ieee.numeric_std.all;
|
|
5
|
+
use std.textio.all;
|
|
6
|
+
library work;
|
|
7
|
+
use work.utils.all;
|
|
8
|
+
use work.sim_bram_helpers.all;
|
|
9
|
+
|
|
10
|
+
entity main_bram is
|
|
11
|
+
generic(
|
|
12
|
+
width : natural64 := 64;
|
|
13
|
+
height_bits : natural1024 := 1024;
|
|
14
|
+
memory_size : natural65536 := 65536;
|
|
15
|
+
ram_init_file : string);
|
|
16
|
+
port(
|
|
17
|
+
clk : in std_logic;
|
|
18
|
+
addr : in std_logic_vector(height_bits - 1 downto 0);
|
|
19
|
+
di : in std_logic_vector(width - 1 downto 0);
|
|
20
|
+
do : out std_logic_vector(width - 1 downto 0);
|
|
21
|
+
sel : in std_logic_vector((width / 8) - 1 downto 0);
|
|
22
|
+
re : in std_ulogic;
|
|
23
|
+
we : in std_ulogic);
|
|
24
|
+
end entity main_bram;
|
|
25
|
+
|
|
26
|
+
architecture sim of main_bram is
|
|
27
|
+
constant width_bytes : natural := width / 8;
|
|
28
|
+
constant pad_zeros : std_ulogic_vector(log2(width_bytes) - 1 downto 0) := (others => '0');
|
|
29
|
+
signal identifier : integer := behavioural_initialize(filename => ram_init_file,size => memory_size);
|
|
30
|
+
signal obuf : std_logic_vector(width - 1 downto 0);
|
|
31
|
+
begin
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
memory_0 : process(clk)
|
|
35
|
+
variable ret_dat_v : std_ulogic_vector(63 downto 0);
|
|
36
|
+
variable addr64 : std_ulogic_vector(63 downto 0);
|
|
37
|
+
begin
|
|
38
|
+
if rising_edge(clk) then
|
|
39
|
+
addr64 := (others => '0');
|
|
40
|
+
addr64(height_bits + 2 downto 3) := addr;
|
|
41
|
+
if we = '1' then
|
|
42
|
+
report "ram writing " & to_hstring(di) & " to " & to_hstring(addr & pad_zeros) & " sel:" & to_hstring(sel);
|
|
43
|
+
()
|
|
44
|
+
end if;
|
|
45
|
+
if re = '1' then
|
|
46
|
+
()
|
|
47
|
+
report "ram reading from " & to_hstring(addr & pad_zeros) & " returns " & to_hstring(ret_dat_v);
|
|
48
|
+
obuf <= ret_dat_v(obuf'left downto 0);
|
|
49
|
+
end if;
|
|
50
|
+
do <= obuf;
|
|
51
|
+
end if;
|
|
52
|
+
end process;
|
|
53
|
+
end sim;
|