vertigo_vhdl 0.8.2
Sign up to get free protection for your applications and to get access to all the features.
- 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/wishbone_types.vhdl
|
@@ -0,0 +1,38 @@
|
|
1
|
+
-- generated by Vertigo VHDL tool
|
2
|
+
library ieee;
|
3
|
+
use ieee.std_logic_1164.all;
|
4
|
+
|
5
|
+
package wishbone_types is
|
6
|
+
constant wishbone_addr_bits : integer := 32;
|
7
|
+
constant wishbone_data_bits : integer := 64;
|
8
|
+
constant wishbone_sel_bits : integer := wishbone_data_bits / 8;
|
9
|
+
|
10
|
+
subtype wishbone_addr_type is std_ulogic_vector(wishbone_addr_bits - 1 downto 0);
|
11
|
+
|
12
|
+
subtype wishbone_data_type is std_ulogic_vector(wishbone_data_bits - 1 downto 0);
|
13
|
+
|
14
|
+
subtype wishbone_sel_type is std_ulogic_vector(wishbone_sel_bits - 1 downto 0);
|
15
|
+
|
16
|
+
type wishbone_master_out is record
|
17
|
+
adr : wishbone_addr_type;
|
18
|
+
dat : wishbone_data_type;
|
19
|
+
cyc : std_ulogic;
|
20
|
+
stb : std_ulogic;
|
21
|
+
sel : wishbone_sel_type;
|
22
|
+
we : std_ulogic;
|
23
|
+
end record;
|
24
|
+
constant wishbone_master_out_init : wishbone_master_out := (cyc => '0',stb => '0',we => '0',others => (others => '0'));
|
25
|
+
|
26
|
+
type wishbone_slave_out is record
|
27
|
+
dat : wishbone_data_type;
|
28
|
+
ack : std_ulogic;
|
29
|
+
stall : std_ulogic;
|
30
|
+
end record;
|
31
|
+
constant wishbone_slave_out_init : wishbone_slave_out := (ack => '0',stall => '0',others => (others => '0'));
|
32
|
+
|
33
|
+
type wishbone_master_out_vector is array(natural range <>) of wishbone_master_out;
|
34
|
+
|
35
|
+
type wishbone_slave_out_vector is array(natural range <>) of wishbone_slave_out;
|
36
|
+
|
37
|
+
end wishbone_types;
|
38
|
+
|
@@ -0,0 +1 @@
|
|
1
|
+
../microwatt/writeback.vhdl
|
@@ -0,0 +1,87 @@
|
|
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.crhelpers.all;
|
8
|
+
|
9
|
+
entity writeback is
|
10
|
+
port(
|
11
|
+
clk : in std_ulogic;
|
12
|
+
e_in : in execute1towritebacktype;
|
13
|
+
l_in : in loadstore1towritebacktype;
|
14
|
+
w_out : out writebacktoregisterfiletype;
|
15
|
+
c_out : out writebacktocrfiletype;
|
16
|
+
complete_out : out std_ulogic);
|
17
|
+
end entity writeback;
|
18
|
+
|
19
|
+
architecture behaviour of writeback is
|
20
|
+
begin
|
21
|
+
|
22
|
+
|
23
|
+
writeback_1 : process(all)
|
24
|
+
variable x : std_ulogic_vector(0 downto 0);
|
25
|
+
variable y : std_ulogic_vector(0 downto 0);
|
26
|
+
variable w : std_ulogic_vector(0 downto 0);
|
27
|
+
variable cf : std_ulogic_vector(3 downto 0);
|
28
|
+
variable zero : std_ulogic;
|
29
|
+
variable sign : std_ulogic;
|
30
|
+
variable scf : std_ulogic_vector(3 downto 0);
|
31
|
+
begin
|
32
|
+
x(0) := e_in.valid;
|
33
|
+
y(0) := l_in.valid;
|
34
|
+
assert (to_integer(unsigned(x)) + to_integer(unsigned(y))) <= 1;
|
35
|
+
x(0) := e_in.write_enable;
|
36
|
+
y(0) := l_in.write_enable;
|
37
|
+
assert (to_integer(unsigned(x)) + to_integer(unsigned(y))) <= 1;
|
38
|
+
w(0) := e_in.write_cr_enable;
|
39
|
+
x(0) := (e_in.write_enable and e_in.rc);
|
40
|
+
assert (to_integer(unsigned(w)) + to_integer(unsigned(x))) <= 1;
|
41
|
+
w_out <= writebacktoregisterfileinit;
|
42
|
+
c_out <= writebacktocrfileinit;
|
43
|
+
complete_out <= '0';
|
44
|
+
if e_in.valid = '1' or l_in.valid = '1' then
|
45
|
+
complete_out <= '1';
|
46
|
+
end if;
|
47
|
+
if e_in.write_enable = '1' then
|
48
|
+
w_out.write_reg <= e_in.write_reg;
|
49
|
+
w_out.write_data <= e_in.write_data;
|
50
|
+
w_out.write_enable <= '1';
|
51
|
+
end if;
|
52
|
+
if e_in.write_cr_enable = '1' then
|
53
|
+
c_out.write_cr_enable <= '1';
|
54
|
+
c_out.write_cr_mask <= e_in.write_cr_mask;
|
55
|
+
c_out.write_cr_data <= e_in.write_cr_data;
|
56
|
+
end if;
|
57
|
+
if e_in.write_xerc_enable = '1' then
|
58
|
+
c_out.write_xerc_enable <= '1';
|
59
|
+
c_out.write_xerc_data <= e_in.xerc;
|
60
|
+
end if;
|
61
|
+
if l_in.write_enable = '1' then
|
62
|
+
w_out.write_reg <= gpr_to_gspr(l_in.write_reg);
|
63
|
+
w_out.write_data <= l_in.write_data;
|
64
|
+
w_out.write_enable <= '1';
|
65
|
+
end if;
|
66
|
+
if l_in.rc = '1' then
|
67
|
+
scf(3) := '0';
|
68
|
+
scf(2) := '0';
|
69
|
+
scf(1) := l_in.store_done;
|
70
|
+
scf(0) := l_in.xerc.so;
|
71
|
+
c_out.write_cr_enable <= '1';
|
72
|
+
c_out.write_cr_mask <= num_to_fxm(0);
|
73
|
+
c_out.write_cr_data(31 downto 28) <= scf;
|
74
|
+
end if;
|
75
|
+
if e_in.rc = '1' and e_in.write_enable = '1' then
|
76
|
+
sign := e_in.write_data(63);
|
77
|
+
zero := (or(e_in.write_data));
|
78
|
+
c_out.write_cr_enable <= '1';
|
79
|
+
c_out.write_cr_mask <= num_to_fxm(0);
|
80
|
+
cf(3) := sign;
|
81
|
+
cf(2) := sign and zero;
|
82
|
+
cf(1) := zero;
|
83
|
+
cf(0) := e_in.xerc.so;
|
84
|
+
c_out.write_cr_data(31 downto 28) <= cf;
|
85
|
+
end if;
|
86
|
+
end process;
|
87
|
+
end behaviour;
|
@@ -0,0 +1,68 @@
|
|
1
|
+
------------------------------------------------------------------------------
|
2
|
+
-- Test Bench for ALU design (ESD figure 2.5)
|
3
|
+
-- by Weijun Zhang, 04/2001
|
4
|
+
--
|
5
|
+
-- we illustrate how to use package and procedure in this example
|
6
|
+
-- it seems a kind of complex testbench for this simple module,
|
7
|
+
-- the method, however, makes huge circuit testing more complete,
|
8
|
+
-- covenient and managable
|
9
|
+
------------------------------------------------------------------------------
|
10
|
+
|
11
|
+
library ieee;
|
12
|
+
use ieee.std_logic_1164.all;
|
13
|
+
use ieee.numeric_std.all;
|
14
|
+
|
15
|
+
-- define constant, signal and procedure within package for ALU
|
16
|
+
|
17
|
+
package ALU_package is
|
18
|
+
|
19
|
+
constant INTERVAL: TIME := 8 ns;
|
20
|
+
|
21
|
+
signal sig_A, sig_B: std_logic_vector(1 downto 0);
|
22
|
+
signal sig_Sel: std_logic_vector(1 downto 0);
|
23
|
+
signal sig_Res: std_logic_vector(1 downto 0);
|
24
|
+
|
25
|
+
procedure load_data(
|
26
|
+
signal A, B: out std_logic_vector(1 downto 0);
|
27
|
+
signal Sel: out std_logic_vector(1 downto 0)
|
28
|
+
);
|
29
|
+
|
30
|
+
procedure check_data(signal Sel: out std_logic_vector( 1 downto 0));
|
31
|
+
|
32
|
+
end ALU_package;
|
33
|
+
|
34
|
+
-- put all the procedure descriptions within package body
|
35
|
+
|
36
|
+
package body ALU_package is
|
37
|
+
|
38
|
+
procedure load_data (signal A, B: out std_logic_vector(1 downto 0);
|
39
|
+
signal Sel: out std_logic_vector(1 downto 0) ) is
|
40
|
+
begin
|
41
|
+
A <= sig_A;
|
42
|
+
B <= sig_B;
|
43
|
+
Sel <= sig_Sel;
|
44
|
+
end load_data;
|
45
|
+
|
46
|
+
procedure check_data (signal Sel: out std_logic_vector( 1 downto 0)) is
|
47
|
+
begin
|
48
|
+
Sel <= sig_Sel;
|
49
|
+
if (sig_Sel="00") then
|
50
|
+
assert(sig_Res = (sig_A + sig_B))
|
51
|
+
report "Error detected in Addition!"
|
52
|
+
severity warning;
|
53
|
+
elsif (sig_Sel="01") then
|
54
|
+
assert(sig_Res = (sig_A - sig_B))
|
55
|
+
report "Error detected in Subtraction!"
|
56
|
+
severity warning;
|
57
|
+
elsif (sig_Sel="10") then
|
58
|
+
assert(sig_Res = (sig_A and sig_B))
|
59
|
+
report "AND Operation Error!"
|
60
|
+
severity warning;
|
61
|
+
elsif (sig_Sel="11") then
|
62
|
+
assert(sig_Res = (sig_A or sig_B))
|
63
|
+
report "OR operation Error!"
|
64
|
+
severity warning;
|
65
|
+
end if;
|
66
|
+
end check_data;
|
67
|
+
|
68
|
+
end ALU_package;
|
@@ -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
|
+
|
6
|
+
package alu_package is
|
7
|
+
constant interval : time := 8 ns;
|
8
|
+
signal sig_a : std_logic_vector(1 downto 0);
|
9
|
+
signal sig_b : std_logic_vector(1 downto 0);
|
10
|
+
signal sig_sel : std_logic_vector(1 downto 0);
|
11
|
+
signal sig_res : std_logic_vector(1 downto 0);
|
12
|
+
|
13
|
+
procedure load_data(
|
14
|
+
a : out std_logic_vector(1 downto 0);
|
15
|
+
b : out std_logic_vector(1 downto 0);
|
16
|
+
sel : out std_logic_vector(1 downto 0));
|
17
|
+
|
18
|
+
procedure check_data(
|
19
|
+
sel : out std_logic_vector(1 downto 0));
|
20
|
+
|
21
|
+
end alu_package;
|
22
|
+
|
23
|
+
package body alu_package is
|
24
|
+
|
25
|
+
procedure load_data(
|
26
|
+
a : out std_logic_vector(1 downto 0);
|
27
|
+
b : out std_logic_vector(1 downto 0);
|
28
|
+
sel : out std_logic_vector(1 downto 0)) is
|
29
|
+
begin
|
30
|
+
a <= sig_a;
|
31
|
+
b <= sig_b;
|
32
|
+
sel <= sig_sel;
|
33
|
+
end load_data;
|
34
|
+
|
35
|
+
procedure check_data(
|
36
|
+
sel : out std_logic_vector(1 downto 0)) is
|
37
|
+
begin
|
38
|
+
sel <= sig_sel;
|
39
|
+
if (sig_sel = "00") then
|
40
|
+
assert (sig_res = (sig_a + sig_b))
|
41
|
+
report "error detected in addition!" severity warning;
|
42
|
+
elsif (sig_sel = "01") then
|
43
|
+
assert (sig_res = (sig_a - sig_b))
|
44
|
+
report "error detected in subtraction!" severity warning;
|
45
|
+
elsif (sig_sel = "10") then
|
46
|
+
assert (sig_res = (sig_a and sig_b))
|
47
|
+
report "and operation error!" severity warning;
|
48
|
+
elsif (sig_sel = "11") then
|
49
|
+
assert (sig_res = (sig_a or sig_b))
|
50
|
+
report "or operation error!" severity warning;
|
51
|
+
end if;
|
52
|
+
end check_data;
|
53
|
+
end alu_package;
|
@@ -0,0 +1,15 @@
|
|
1
|
+
library ieee;
|
2
|
+
use ieee.std_logic_1164.all;
|
3
|
+
use ieee.numeric_std.all;
|
4
|
+
|
5
|
+
entity test is
|
6
|
+
end entity;
|
7
|
+
|
8
|
+
architecture arch of test is
|
9
|
+
constant CST : std_logic_vector(15 downto 0) := x"1234";
|
10
|
+
signal s1,s2 : std_logic_vector(31 downto 0);
|
11
|
+
begin
|
12
|
+
|
13
|
+
s2 <= s1(15 downto 0) & CST;
|
14
|
+
|
15
|
+
end architecture;
|
@@ -0,0 +1,16 @@
|
|
1
|
+
-- generated by Vertigo VHDL tool
|
2
|
+
library ieee;
|
3
|
+
use ieee.std_logic_1164.all;
|
4
|
+
use ieee.numeric_std.all;
|
5
|
+
|
6
|
+
entity test is
|
7
|
+
end entity test;
|
8
|
+
|
9
|
+
architecture arch of test is
|
10
|
+
constant cst : std_logic_vector(15 downto 0) := x"1234";
|
11
|
+
signal s1 : std_logic_vector(31 downto 0);
|
12
|
+
signal s2 : std_logic_vector(31 downto 0);
|
13
|
+
begin
|
14
|
+
|
15
|
+
s2 <= s1(15 downto 0) & cst;
|
16
|
+
end arch;
|
@@ -0,0 +1,94 @@
|
|
1
|
+
|
2
|
+
|
3
|
+
library IEEE;
|
4
|
+
use IEEE.std_logic_1164.all;
|
5
|
+
use IEEE.std_logic_arith.all;
|
6
|
+
|
7
|
+
entity DECODER_TB is
|
8
|
+
end DECODER_TB;
|
9
|
+
|
10
|
+
architecture TB of DECODER_TB is
|
11
|
+
|
12
|
+
signal T_I : std_logic_vector(1 downto 0) := "00";
|
13
|
+
signal T_O : std_logic_vector(3 downto 0);
|
14
|
+
|
15
|
+
|
16
|
+
component decoder port(
|
17
|
+
I : in std_logic_vector(1 downto 0);
|
18
|
+
O : out std_logic_vector(3 downto 0)
|
19
|
+
);
|
20
|
+
end component;
|
21
|
+
|
22
|
+
begin
|
23
|
+
|
24
|
+
U_DECODER : DECODER port map (T_I, T_O);
|
25
|
+
|
26
|
+
process
|
27
|
+
variable err_cnt : integer := 0;
|
28
|
+
begin
|
29
|
+
|
30
|
+
wait for 10 ns;
|
31
|
+
T_I <= "00";
|
32
|
+
wait for 1 ns;
|
33
|
+
assert (T_O="0001") report "Error Case 0" severity error;
|
34
|
+
if (T_O/="0001") then
|
35
|
+
err_cnt := err_cnt + 1;
|
36
|
+
end if;
|
37
|
+
|
38
|
+
|
39
|
+
wait for 10 ns;
|
40
|
+
T_I <= "01";
|
41
|
+
wait for 1 ns;
|
42
|
+
assert (T_O="0010") report "Error Case 1"
|
43
|
+
severity error;
|
44
|
+
if (T_O/="0010") then
|
45
|
+
err_cnt := err_cnt + 1;
|
46
|
+
end if;
|
47
|
+
|
48
|
+
|
49
|
+
wait for 10 ns;
|
50
|
+
T_I <= "10";
|
51
|
+
wait for 1 ns;
|
52
|
+
assert (T_O="0100") report "Error Case 2"
|
53
|
+
severity error;
|
54
|
+
if (T_O/="0100") then
|
55
|
+
err_cnt := err_cnt + 1;
|
56
|
+
end if;
|
57
|
+
|
58
|
+
|
59
|
+
wait for 10 ns;
|
60
|
+
T_I <= "11";
|
61
|
+
wait for 1 ns;
|
62
|
+
assert (T_O="1000") report "Error Case 3"
|
63
|
+
severity error;
|
64
|
+
if (T_O/="1000") then
|
65
|
+
err_cnt := err_cnt + 1;
|
66
|
+
end if;
|
67
|
+
|
68
|
+
|
69
|
+
wait for 10 ns;
|
70
|
+
T_I <= "UU";
|
71
|
+
|
72
|
+
|
73
|
+
if (err_cnt=0) then
|
74
|
+
assert false
|
75
|
+
report "Testbench of Adder completed successfully!"
|
76
|
+
severity note;
|
77
|
+
else
|
78
|
+
assert true
|
79
|
+
report "Something wrong, try again"
|
80
|
+
severity error;
|
81
|
+
end if;
|
82
|
+
|
83
|
+
wait;
|
84
|
+
|
85
|
+
end process;
|
86
|
+
|
87
|
+
end TB;
|
88
|
+
|
89
|
+
---------------------------------------------------------------
|
90
|
+
configuration CFG_TB of DECODER_TB is
|
91
|
+
for TB
|
92
|
+
end for;
|
93
|
+
end CFG_TB;
|
94
|
+
----------------------------------------------------------------
|