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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [orpsocv2/] [rtl/] [verilog/] [intgen/] [intgen.v] - Blame information for rev 506

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 506 julius
/*
2
 *
3
 * Interrupt generation module
4
 *
5
 * A counter is loaded with a value over the Wishbone bus interface, which then
6
 * counts down and issues an interrupt when the value is 1
7
 *
8
 *
9
 * Register 0 - write only - counter value
10
 *
11
 * Register 1 - read/write - interrupt status/clear
12
 *
13
 */
14
 
15
module intgen(
16
              clk_i,
17
              rst_i,
18
              wb_adr_i,
19
              wb_cyc_i,
20
              wb_stb_i,
21
              wb_dat_i,
22
              wb_we_i,
23
              wb_ack_o,
24
              wb_dat_o,
25
 
26
              irq_o
27
              );
28
 
29
 
30
   input clk_i;
31
   input rst_i;
32
 
33
   input wb_adr_i;
34
   input wb_cyc_i;
35
   input wb_stb_i;
36
   input [7:0] wb_dat_i;
37
   input       wb_we_i;
38
   output      wb_ack_o;
39
   output [7:0] wb_dat_o;
40
 
41
   output reg   irq_o;
42
 
43
   reg [7:0]     counter;
44
 
45
   always @(posedge clk_i or posedge rst_i)
46
     if (rst_i)
47
       counter <= 0;
48
     else if (wb_stb_i & wb_cyc_i & wb_we_i & !wb_adr_i)
49
       // Write to adress 0 loads counter
50
       counter <= wb_dat_i;
51
     else if (|counter)
52
       counter <= counter - 1;
53
 
54
   always @(posedge clk_i or posedge rst_i)
55
     if (rst_i)
56
       irq_o <= 0;
57
     else if (wb_stb_i & wb_cyc_i & wb_we_i & wb_adr_i)
58
       // Clear on write to reg 1
59
       irq_o <= 0;
60
     else if (counter==8'd1)
61
       irq_o <= 1;
62
 
63
   assign wb_ack_o = wb_stb_i & wb_cyc_i;
64
   assign wb_dat_o = (wb_adr_i) ? {7'd0,irq_o} : counter;
65
 
66
endmodule // intgen
67
 
68
 
69
 
70
 

powered by: WebSVN 2.1.0

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