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

Subversion Repositories versatile_io

[/] [versatile_io/] [trunk/] [rtl/] [verilog/] [top/] [versatile_io_top.v] - Blame information for rev 4

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 unneback
`include "include/versatile_io_defines.v"
2
`ifdef UART0
3
`include "uart16550_ip.v"
4
`endif
5
module versatile_io (
6
    input [31:0] wbs_dat_i,
7
    input [31:0] wbs_adr_i,
8
    input [3:0] wbs_sel_i,
9
    input wbs_we_i, wbs_stb_i, wbs_cyc_i,
10
    output [31:0] wbs_dat_o,
11 4 unneback
    output wbs_ack_o,
12 2 unneback
`ifdef B4
13
    output wbs_stall_o,
14
`endif
15
`include "versatile_io_module.v"
16
`ifdef UART0
17
    output uart0_irq,
18
`endif
19
    input wbs_clk, wbs_rst,
20
    input clk, rst
21
);
22
 
23 4 unneback
`ifdef UART0
24
parameter uart0_mem_map_hi = `UART0_MEM_MAP_HI;
25
parameter uart0_mem_map_lo = `UART0_MEM_MAP_LO;
26
parameter [31:0] uart0_base_adr = `UART0_BASE_ADR;
27
`endif
28 2 unneback
function [7:0] tobyte;
29
input [3:0] sel_i;
30
input [31:0] dat_i;
31
begin
32
    tobyte = ({8{sel_i[3]}} & dat_i[31:24]) | ({8{sel_i[2]}} & dat_i[23:16]) | ({8{sel_i[1]}} & dat_i[15:8]) | ({8{sel_i[0]}} & dat_i[7:0]);
33 4 unneback
end
34 2 unneback
endfunction
35
 
36
function [31:0] toword;
37
input [7:0] dat_i;
38
begin
39
    toword = {4{dat_i}};
40 4 unneback
end
41 2 unneback
endfunction
42
 
43
function [31:0] mask;
44
input [31:0] dat_i;
45
input sel;
46
begin
47
    mask = {32{sel}} & dat_i;
48
end
49
endfunction
50
 
51
`ifdef UART0
52 4 unneback
wire uart0_cs;
53
assign uart0_cs = wbs_adr_i[uart0_mem_map_hi:uart0_mem_map_lo] == uart0_base_adr[uart0_mem_map_hi:uart0_mem_map_lo];
54 2 unneback
wire [7:0] uart0_temp;
55
wire uart0_ack_o;
56
uart_top uart0  (
57 4 unneback
    .wb_clk_i(wbs_clk), .wb_rst_i(wbs_rst),
58 2 unneback
    // Wishbone signals
59
    .wb_adr_i(wbs_adr_i[2:0]), .wb_dat_i(tobyte(wbs_sel_i,wbs_dat_i)), .wb_dat_o(uart0_temp), .wb_we_i(wbs_we_i), .wb_stb_i(wbs_stb_i), .wb_cyc_i(wbs_cyc_i & uart0_cs), .wb_ack_o(uart0_ack_o), .wb_sel_i(4'b0),
60
    .int_o(uart0_irq), // interrupt request
61
    // UART     signals
62
    // serial input/output
63
    .stx_pad_o(uart0_tx_pad_i), .srx_pad_i(uart0_rx_pad_i),
64
    // modem signals
65
    .rts_pad_o(), .cts_pad_i(1'b0), .dtr_pad_o(), .dsr_pad_i(1'b0), .ri_pad_i(1'b0), .dcd_pad_i(1'b0) );
66
assign uart0_dat_o = mask( toword(uart0_temp), uart0_ack_o);
67
`else
68
assign uart0_dat_o = 32'h0;
69
assign uart0_ack_o = 1'b0;
70
`endif
71
 
72
assign wbs_dat_o = uart0_dat_o;
73
assign wbs_ack_o = uart0_ack_o;
74
`ifdef WB4
75
assign wbs_stall_o = 1'b0;
76
`endif
77
 
78
endmodule

powered by: WebSVN 2.1.0

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