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

Subversion Repositories apb2spi

[/] [apb2spi/] [trunk/] [tb/] [env/] [apb_agent/] [apb_slave.v] - Blame information for rev 15

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 15 vlnaran
`timescale 1ns/1ps
2
 
3
module apb_slave(input [3:0] paddr,
4
                input pwrite,
5
                input [1:0] psel,
6
                input penable,
7
                output reg pready,
8
                input [31:0] pwdata,
9
                output reg [31:0] prdata,
10
                input pclk,
11
                input presetn);
12
 
13
                reg [31:0] spcr,spdr,wr_data;
14
 
15
                always@(posedge pclk or negedge presetn)
16
                if(!presetn)
17
                        pready <= 1'b0;
18
                else if(penable==1'b1)
19
                        pready <= 1'b1;
20
 
21
                always@(posedge pclk or negedge presetn)
22
                if(!presetn)
23
                        spcr <= 32'h0;
24
                else if(psel==2'b01 && pready && penable && pwrite && paddr==4'b0001)
25
                        spcr <= pwdata;
26
 
27
                always@(posedge pclk or negedge presetn)
28
                if(!presetn)
29
                        spdr <= 32'h0;
30
                else if(psel==2'b01 && pready && penable && pwrite && paddr==4'b0010)
31
                        spdr <= pwdata;
32
 
33
                always@(posedge pclk or negedge presetn)
34
                if(!presetn)
35
                        wr_data <= 32'h0;
36
                else if(psel==2'b01 && pready && penable && pwrite && paddr==4'b0011)
37
                        wr_data <= pwdata;
38
 
39
                always@(posedge pclk or negedge presetn)
40
                if(!presetn)
41
                        prdata <= 32'h0;
42
                else if(psel==2'b01 && pready && penable && !pwrite && paddr==4'b0001)
43
                        prdata <= spcr;
44
                else if(psel==2'b01 && pready && penable && !pwrite && paddr==4'b0010)
45
                        prdata <= spdr;
46
                else if(psel==2'b01 && pready && penable && !pwrite && paddr==4'b0011)
47
                        prdata <= wr_data;
48
 
49
endmodule
50
 

powered by: WebSVN 2.1.0

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