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

Subversion Repositories mips_16

[/] [mips_16/] [trunk/] [rtl/] [mips_16_core_top.v] - Blame information for rev 4

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 4 Doyya
/***************************************************
2
 * Module: mips_16_core_top
3
 * Project: mips_16
4
 * Author: fzy
5
 * Description:
6
 *     top module of mips_16 cpu core. Technical details:
7
 *                      1.      16-bit data width
8
 *                      2.      classic 5-stage static pipeline, 1 branch delay slot, theoretical CPI is 1.0
9
 *                      3.      pipeline is able to detect and prevent RAW hazards, no forwarding logic
10
 *                      4.      8 general purpose register (reg 0 is special, according to mips architecture)
11
 *                      5.      up to now supports 13 instrcutions, see ./doc/instruction_set.txt for details
12
 *
13
 * Revise history:
14
 *
15
 ***************************************************/
16
`timescale 1ns/1ps
17
`include "mips_16_defs.v"
18
module mips_16_core_top
19
(
20
        input                                           clk,
21
        input                                           rst,
22
 
23
        output  [`PC_WIDTH-1:0]          pc
24
);
25
        wire                                            pipeline_stall_n ;
26
        wire    [5:0]                            branch_offset_imm;
27
        wire                                            branch_taken;
28
        wire    [15:0]                           instruction;
29
        wire    [56:0]                           ID_pipeline_reg_out;
30
        wire    [37:0]                           EX_pipeline_reg_out;
31
        wire    [36:0]                           MEM_pipeline_reg_out;
32
 
33
        wire    [2:0]                            reg_read_addr_1;        // register file read port 1 address
34
        wire    [2:0]                            reg_read_addr_2;        // register file read port 2 address
35
        wire    [15:0]                           reg_read_data_1;        // register file read port 1 data
36
        wire    [15:0]                           reg_read_data_2;        // register file read port 2 data
37
        wire    [2:0]                            decoding_op_src1;               //source_1 register number
38
        wire    [2:0]                            decoding_op_src2;               //source_2 register number
39
        wire    [2:0]                            ex_op_dest;                             //EX stage destinaton register number
40
        wire    [2:0]                            mem_op_dest;                    //MEM stage destinaton register number
41
        wire    [2:0]                            wb_op_dest;                             //WB stage destinaton register number
42
        wire                                            reg_write_en;
43
        wire    [2:0]                            reg_write_dest;
44
        wire    [15:0]                           reg_write_data;
45
 
46
        IF_stage IF_stage_inst (
47
                .clk                                    (clk),
48
                .rst                                    (rst),
49
                .instruction_fetch_en   (pipeline_stall_n),
50
                .branch_offset_imm              (branch_offset_imm),
51
                .branch_taken                   (branch_taken),
52
                .pc                                             (pc),
53
                .instruction                    (instruction)
54
        );
55
 
56
        ID_stage ID_stage_inst (
57
                .clk                                    (clk),
58
                .rst                                    (rst),
59
                .instruction_decode_en  (pipeline_stall_n),
60
                .pipeline_reg_out               (ID_pipeline_reg_out),
61
                .instruction                    (instruction),
62
                .branch_offset_imm              (branch_offset_imm),
63
                .branch_taken                   (branch_taken),
64
                .reg_read_addr_1                (reg_read_addr_1),      //
65
                .reg_read_addr_2                (reg_read_addr_2),      //
66
                .reg_read_data_1                (reg_read_data_1),      //
67
                .reg_read_data_2                (reg_read_data_2),      //
68
                .decoding_op_src1               (decoding_op_src1),
69
                .decoding_op_src2               (decoding_op_src2)
70
        );
71
 
72
        EX_stage EX_stage_inst (
73
                .clk                                    (clk),
74
                .rst                                    (rst),
75
                .pipeline_reg_in                (ID_pipeline_reg_out),
76
                .pipeline_reg_out               (EX_pipeline_reg_out),
77
                .ex_op_dest                             (ex_op_dest)
78
        );
79
 
80
        MEM_stage MEM_stage_inst (
81
                .clk                                    (clk),
82
                .rst                                    (rst),
83
                .pipeline_reg_in                (EX_pipeline_reg_out),
84
                .pipeline_reg_out               (MEM_pipeline_reg_out),
85
                .mem_op_dest                    (mem_op_dest)
86
        );
87
 
88
        WB_stage WB_stage_inst (
89
                .pipeline_reg_in                (MEM_pipeline_reg_out),
90
                .reg_write_en                   (reg_write_en),
91
                .reg_write_dest                 (reg_write_dest),
92
                .reg_write_data                 (reg_write_data),
93
                .wb_op_dest                             (wb_op_dest)
94
        );
95
 
96
        register_file register_file_inst (
97
                .clk                                    (clk),
98
                .rst                                    (rst),
99
                .reg_write_en                   (reg_write_en),
100
                .reg_write_dest                 (reg_write_dest),
101
                .reg_write_data                 (reg_write_data),
102
                .reg_read_addr_1                (reg_read_addr_1),
103
                .reg_read_data_1                (reg_read_data_1),
104
                .reg_read_addr_2                (reg_read_addr_2),
105
                .reg_read_data_2                (reg_read_data_2)
106
        );
107
 
108
        hazard_detection_unit hazard_detection_unit_inst (
109
                .decoding_op_src1               (decoding_op_src1),
110
                .decoding_op_src2               (decoding_op_src2),
111
                .ex_op_dest                             (ex_op_dest),
112
                .mem_op_dest                    (mem_op_dest),
113
                .wb_op_dest                             (wb_op_dest),
114
                .pipeline_stall_n               (pipeline_stall_n)
115
        );
116
 
117
endmodule
118
 
119
 
120
 
121
 
122
 
123
 
124
 
125
 
126
 

powered by: WebSVN 2.1.0

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