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

Subversion Repositories iso7816_3_master

[/] [iso7816_3_master/] [trunk/] [test/] [TriWire.v] - Blame information for rev 14

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

Line No. Rev Author Line
1 11 acapola
/*
2
Author: Sebastien Riou (acapola)
3
Creation date: 14:22:43 01/29/2011
4
 
5
$LastChangedDate: 2011-01-29 13:16:17 +0100 (Sat, 29 Jan 2011) $
6
$LastChangedBy: acapola $
7
$LastChangedRevision: 11 $
8
$HeadURL: file:///svn/iso7816_3_master/iso7816_3_master/trunk/test/TriWire.v $
9
 
10
This file is under the BSD licence:
11
Copyright (c) 2011, Sebastien Riou
12
 
13
All rights reserved.
14
 
15
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
16
 
17
Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
18
Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
19
The names of contributors may not be used to endorse or promote products derived from this software without specific prior written permission.
20
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
24
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
25
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
26
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
27
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
28
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
29
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
30
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31
*/
32
`default_nettype none
33 10 acapola
`timescale 1ns / 1ps
34 11 acapola
 
35 10 acapola
/*****************************************************************
36
* module triwire: bidirectional wire bus model with delay
37
*
38
* This module models the two ends of a bidirectional bus with
39
* transport (not inertial) delays in each direction. The
40
* bus has a width of WIDTH and the delays are as follows:
41
* a->b has a delay of Ta_b (in `timescale units)
42
* b->a has a delay of Tb_a (in `timescale units)
43
* The two delays will typically be the same. This model
44
* overcomes the problem of "echoes" at the receiving end of the
45
* wire by ensuring that data is only transmitted down the wire
46
* when the received data is Z. That means that there may be
47
* collisions resulting in X at the local end, but X's are not
48
* transmitted to the other end, which is a limitation of the
49
* model. Another compromise made in the interest of simulation
50
* speed is that the bus is not treated as individual wires, so
51
* a Z on any single wire may prevent data from being transmitted
52
* on other wires.
53
*
54
* The delays are reals so that they may vary throughout the
55
* course of a simulation. To change the delay, use the Verilog
56
* force command. Here is an example instantiation template:
57
*
58
real Ta_b=1, Tb_a=1;
59
always(Ta_b) force triwire.Ta_b = Ta_b;
60
always(Tb_a) force triwire.Tb_a = Tb_a;
61
triwire #(.WIDTH(WIDTH)) triwire (.a(a),.b(b));
62
 
63
* Kevin Neilson, Xilinx, 2007
64
*****************************************************************/
65
module triwire #(parameter WIDTH=1) (inout wire [WIDTH-1:0] a, b);
66
        real Ta_b=1, Tb_a=1;
67
        reg [WIDTH-1:0] a_dly = 'bz, b_dly = 'bz;
68
        always @(a) a_dly <= #(Ta_b) b_dly==={WIDTH{1'bz}} ? a : 'bz;
69
        always @(b) b_dly <= #(Tb_a) a_dly==={WIDTH{1'bz}} ? b : 'bz;
70
        assign b = a_dly, a = b_dly;
71
endmodule
72
 
73
//delay fixed at build time here
74
//Sebastien Riou
75
module TriWirePullup #(parameter UNIDELAY=1)
76
                                                        (inout wire a, b);
77
        reg a_dly = 'bz, b_dly = 'bz;
78
        always @(a) begin
79
                if(b_dly!==1'b0) begin
80
                        if(a===1'b0)
81
                                a_dly <= #(UNIDELAY) 1'b0;
82
                        else
83
                                a_dly <= #(UNIDELAY) 1'bz;
84
                end
85
        end
86
        always @(b) begin
87
                if(a_dly!==1'b0) begin
88
                        if(b===1'b0)
89
                                b_dly <= #(UNIDELAY) 1'b0;
90
                        else
91
                                b_dly <= #(UNIDELAY) 1'bz;
92
                end
93
        end
94
        assign b = a_dly, a = b_dly;
95
        pullup(a);
96
        pullup(b);
97
endmodule
98
/*module TriWireFixed #(parameter WIDTH=1)
99
                                                        (inout wire [WIDTH-1:0] a, b);
100
        tran (a,b);//not supported by xilinx ISE, even just in simulation :-S
101
        specify
102
                (a*>b)=(1,1);
103
                (b*>a)=(1,1);
104
        endspecify
105
endmodule */
106 11 acapola
`default_nettype wire

powered by: WebSVN 2.1.0

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