OpenCores
URL https://opencores.org/ocsvn/mcs-4/mcs-4/trunk

Subversion Repositories mcs-4

[/] [mcs-4/] [trunk/] [rtl/] [verilog/] [common/] [counter.v] - Blame information for rev 6

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 rrpollack
`timescale 1ns / 1ps
2
`default_nettype none
3
////////////////////////////////////////////////////////////////////////
4 6 rrpollack
//
5
// MCS-4 common counter sub-module
6
//
7
// This module emulates the counter logic found in Intel MCS-4
8
// integrated circuits such as the i4004 CPU.
9
//
10 2 rrpollack
// This file is part of the MCS-4 project hosted at OpenCores:
11
//      http://www.opencores.org/cores/mcs-4/
12 6 rrpollack
//
13
// Copyright © 2012, 2021 by Reece Pollack <rrpollack@opencores.org>
14
//
15 2 rrpollack
// These materials are provided under the Creative Commons
16 6 rrpollack
// "Attribution-NonCommercial-ShareAlike" (CC BY-NC-SA) Public License.
17
// They are NOT "public domain", and are protected by copyright.
18
//
19 2 rrpollack
// This work based on materials provided by Intel Corporation and
20
// others under the same license. See the file doc/License for
21
// details of this license.
22
//
23
////////////////////////////////////////////////////////////////////////
24
 
25 6 rrpollack
module counter (
26
    input  wire sysclk,
27 2 rrpollack
 
28 6 rrpollack
    input  wire step_a_in,
29
    input  wire step_b_in,
30 2 rrpollack
 
31 6 rrpollack
    output wire step_a_out,
32
    output wire step_b_out,
33
    output wire q,
34
    output wire qn
35
    );
36
 
37
    reg  master = 1'b0;
38
    reg  slave  = 1'b0;
39
    always @(posedge sysclk) begin
40
        if (step_a_in)
41
            master <= ~slave;
42
    end
43
 
44
    always @(posedge sysclk) begin
45
        if (step_b_in)
46
            slave  <= master;
47
    end
48
 
49
    assign step_a_out =  slave;
50
    assign step_b_out = ~slave;
51
 
52
    assign q  = step_a_out;
53
    assign qn = step_b_out;
54
 
55 2 rrpollack
endmodule

powered by: WebSVN 2.1.0

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