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

Subversion Repositories tiny_tate_bilinear_pairing

[/] [tiny_tate_bilinear_pairing/] [trunk/] [group_size_is_151_bits/] [testbench/] [test_fsm.v] - Blame information for rev 15

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 15 homer.hsin
/*
2
 * Copyright 2012, Homer Hsing <homer.hsing@gmail.com>
3
 *
4
 * Licensed under the Apache License, Version 2.0 (the "License");
5
 * you may not use this file except in compliance with the License.
6
 * You may obtain a copy of the License at
7
 *
8
 * http://www.apache.org/licenses/LICENSE-2.0
9
 *
10
 * Unless required by applicable law or agreed to in writing, software
11
 * distributed under the License is distributed on an "AS IS" BASIS,
12
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
 * See the License for the specific language governing permissions and
14
 * limitations under the License.
15
 */
16
 
17 3 homer.hsin
`timescale 1ns / 1ps
18
`define P 20 // clock period
19
 
20 5 homer.hsin
module test_fsm;
21 3 homer.hsin
 
22
        // Inputs
23
        reg clk;
24
        reg reset;
25
        reg [25:0] rom_q;
26
 
27
        // Outputs
28
        wire [8:0] rom_addr;
29
        wire [5:0] ram_a_addr;
30
        wire [5:0] ram_b_addr;
31
        wire ram_b_w;
32
        wire [10:0] pe;
33
        wire done;
34
 
35
        // Instantiate the Unit Under Test (UUT)
36
        FSM uut (
37
                .clk(clk),
38
                .reset(reset),
39
                .rom_addr(rom_addr),
40
                .rom_q(rom_q),
41
                .ram_a_addr(ram_a_addr),
42
                .ram_b_addr(ram_b_addr),
43
                .ram_b_w(ram_b_w),
44
                .pe(pe),
45
                .done(done)
46
        );
47
 
48
        initial begin
49
                // Initialize Inputs
50
                clk = 0;
51
                reset = 0;
52
 
53
                // Wait 100 ns for global reset to finish
54
                #100;
55
 
56
                // Add stimulus here
57
        #(`P/2); reset = 1; #(`P); reset = 0;
58
 
59
        @(posedge done);
60
        $finish;
61
        end
62
 
63
    initial #100 forever #(`P/2) clk = ~clk;
64
 
65
    /* rom code format
66
     * wire [5:0] dest, src1, src2, times; wire [1:0] op;
67
     * assign {dest, src1, op, times, src2} = rom_q;
68
     */
69
    parameter ADD=2'd0, SUB=2'd1, CUBIC=2'd2, MULT=2'd3;
70
 
71
    always @ (posedge clk)
72
        case(rom_addr)
73
        0: rom_q <= {6'd10, 6'd11, ADD, 6'd1, 6'd12};
74
        1: rom_q <= {6'd20, 6'd21, SUB, 6'd1, 6'd22};
75
        2: rom_q <= {6'd30, 6'd31, CUBIC, 6'd5, 6'd32};
76
        3: rom_q <= {6'd40, 6'd41, MULT, 6'd33, 6'd42};
77
        default: rom_q <= 0;
78
        endcase
79
endmodule
80
 

powered by: WebSVN 2.1.0

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