OpenCores
URL https://opencores.org/ocsvn/mod_mult_exp/mod_mult_exp/trunk

Subversion Repositories mod_mult_exp

[/] [mod_mult_exp/] [trunk/] [bench/] [vhdl/] [commons/] [ShiftRegTB.vhd] - Blame information for rev 6

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 6 gajos
----                                                               ----
2
---- This file is part of the Montgomery modular multiplier        ----
3
---- and exponentiator                                             ----
4
---- https://opencores.org/projects/mod_mult_exp                   ----
5
----                                                               ----
6
---- Description:                                                  ----
7
----     Test bench of shift register - nothing special.           ----
8
---- To Do:                                                        ----
9
----                                                               ----
10
---- Author(s):                                                    ----
11
---- - Krzysztof Gajewski, gajos@opencores.org                     ----
12
----                       k.gajewski@gmail.com                    ----
13
----                                                               ----
14
-----------------------------------------------------------------------
15
----                                                               ----
16
---- Copyright (C) 2019 Authors and OPENCORES.ORG                  ----
17
----                                                               ----
18
---- This source file may be used and distributed without          ----
19
---- restriction provided that this copyright statement is not     ----
20
---- removed from the file and that any derivative work contains   ----
21
---- the original copyright notice and the associated disclaimer.  ----
22
----                                                               ----
23
---- This source file is free software; you can redistribute it    ----
24
---- and-or modify it under the terms of the GNU Lesser General    ----
25
---- Public License as published by the Free Software Foundation;  ----
26
---- either version 2.1 of the License, or (at your option) any    ----
27
---- later version.                                                ----
28
----                                                               ----
29
---- This source is distributed in the hope that it will be        ----
30
---- useful, but WITHOUT ANY WARRANTY; without even the implied    ----
31
---- warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR       ----
32
---- PURPOSE. See the GNU Lesser General Public License for more   ----
33
---- details.                                                      ----
34
----                                                               ----
35
---- You should have received a copy of the GNU Lesser General     ----
36
---- Public License along with this source; if not, download it    ----
37
---- from http://www.opencores.org/lgpl.shtml                      ----
38
----                                                               ----
39
-----------------------------------------------------------------------
40
LIBRARY ieee;
41
USE ieee.std_logic_1164.ALL;
42
use work.properties.ALL;
43
 
44
-- Uncomment the following library declaration if using
45
-- arithmetic functions with Signed or Unsigned values
46
--USE ieee.numeric_std.ALL;
47
 
48
ENTITY ShiftRegTB IS
49
END ShiftRegTB;
50
 
51
ARCHITECTURE behavior OF ShiftRegTB IS
52
 
53
    -- Component Declaration for the Unit Under Test (UUT)
54
 
55
    COMPONENT ShiftReg
56
         GENERIC (
57
             length_1      : integer :=  BYTE;
58
             length_2      : integer :=  WORD_LENGTH
59
         );
60
    PORT(
61
        input  : in  STD_LOGIC_VECTOR(BYTE - 1 downto 0);
62
        output : out STD_LOGIC_VECTOR(WORD_LENGTH - 1 downto 0);
63
        en     : in  STD_LOGIC;
64
        shift  : in  STD_LOGIC;
65
        clk    : in  STD_LOGIC;
66
        reset  : in  STD_LOGIC
67
    );
68
    END COMPONENT;
69
 
70
 
71
   --Inputs
72
   signal input : STD_LOGIC_VECTOR(BYTE - 1  downto 0) := (others => '0');
73
   signal en    : STD_LOGIC := '0';
74
   signal shift : STD_LOGIC := '0';
75
   signal clk   : STD_LOGIC := '0';
76
   signal reset : STD_LOGIC := '0';
77
 
78
        --Outputs
79
   signal output : STD_LOGIC_VECTOR(WORD_LENGTH - 1 downto 0);
80
 
81
   -- Clock period definitions
82
   constant clk_period : time := 10 ns;
83
 
84
BEGIN
85
 
86
        -- Instantiate the Unit Under Test (UUT)
87
   uut: ShiftReg PORT MAP (
88
          input => input,
89
          output => output,
90
          en => en,
91
          shift => shift,
92
          clk => clk,
93
          reset => reset
94
        );
95
 
96
   -- Clock process definitions
97
   clk_process :process
98
   begin
99
                clk <= '0';
100
                wait for clk_period/2;
101
                clk <= '1';
102
                wait for clk_period/2;
103
   end process;
104
 
105
 
106
  -- Stimulus process
107
   stim_proc: process
108
   begin
109
      reset <= '0';
110
                shift <= '0';
111
                input <= "10101010";
112
      wait for 100 ns;
113
                reset <= '1';
114
      wait for clk_period*10;
115
 
116
                reset <= '0';
117
                en <= '1';
118
                wait for clk_period*1;
119
 
120
                en <= '0';
121
                wait for clk_period*1;
122
 
123
------------- Test case 1 ------------------------
124
--   expected_output <= x"aa00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000";
125
--------------------------------------------------
126
 
127
                if output /= x"aa000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000" then
128
                        report "RESULT MISMATCH! Test case 1 failed" severity ERROR;
129
                        assert false severity failure;
130
                else
131
                        report "Test case 1 successful" severity note;
132
                end if;
133
 
134
                shift <= '1';
135
                wait for clk_period*10;
136
 
137
------------- Test case 2 ------------------------
138
--   expected_output <= x"002a800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000";
139
--------------------------------------------------
140
 
141
                if output /= x"002a8000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000" then
142
                        report "RESULT MISMATCH! Test case 2 failed" severity ERROR;
143
                        assert false severity failure;
144
                else
145
                        report "Test case 2 successful" severity note;
146
                end if;
147
 
148
 
149
                assert false severity failure;
150
   end process;
151
 
152
END;

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.