Add missing snapshots (batch 12/24)
#21
by Zanehpn - opened
This view is limited to 50 files because it contains too many changes. See the raw diff here.
- .gitattributes +16 -0
- snapshots/jotego_jtcores_pr1270/modules/jtframe/src/jtutil/cmd/mra.go +252 -0
- snapshots/jotego_jtcores_pr1270/modules/jtframe/src/jtutil/cmd/root.go +66 -0
- snapshots/jotego_jtcores_pr1270/modules/jtframe/src/jtutil/cmd/sdram.go +281 -0
- snapshots/jotego_jtcores_pr1270/modules/jtframe/src/jtutil/cmd/split16.go +77 -0
- snapshots/jotego_jtcores_pr1270/modules/jtframe/src/jtutil/cmd/tilemap.go +278 -0
- snapshots/jotego_jtcores_pr1270/modules/jtframe/src/jtutil/cmd/trace.go +145 -0
- snapshots/jotego_jtcores_pr1270/modules/jtframe/src/jtutil/cmd/vcd.go +50 -0
- snapshots/jotego_jtcores_pr1270/modules/jtframe/src/jtutil/cmd/verilog.go +50 -0
- snapshots/jotego_jtcores_pr1270/modules/jtframe/src/jtutil/cmd/wav/parser.go +135 -0
- snapshots/jotego_jtcores_pr1270/modules/jtframe/src/jtutil/cmd/wav/wav.go +50 -0
- snapshots/jotego_jtcores_pr1270/modules/jtframe/src/jtutil/go.mod +33 -0
- snapshots/jotego_jtcores_pr1270/modules/jtframe/src/jtutil/go.sum +87 -0
- snapshots/jotego_jtcores_pr1270/modules/jtframe/src/jtutil/main.go +24 -0
- snapshots/jotego_jtcores_pr1270/modules/jtframe/src/jtutil/vcd/compare.go +212 -0
- snapshots/jotego_jtcores_pr1270/modules/jtframe/src/jtutil/vcd/lnfile.go +70 -0
- snapshots/jotego_jtcores_pr1270/modules/jtframe/src/jtutil/vcd/state.go +65 -0
- snapshots/jotego_jtcores_pr1270/modules/jtframe/src/jtutil/vcd/vcd2hex.go +102 -0
- snapshots/jotego_jtcores_pr1270/modules/jtframe/src/jtutil/vcd/vcd_cmd.go +816 -0
- snapshots/jotego_jtcores_pr1270/modules/jtframe/src/jtutil/vcd/vcd_cmd_test.go +31 -0
- snapshots/jotego_jtcores_pr1270/modules/jtframe/src/jtutil/vcd/vcd_parser.go +578 -0
- snapshots/jotego_jtcores_pr1270/modules/jtframe/syn/cpu/pauloblaze.qip +7 -0
- snapshots/jotego_jtcores_pr1270/modules/jtframe/syn/jtframe_2308/adc_test.sdc +2 -0
- snapshots/jotego_jtcores_pr1270/modules/jtframe/syn/jtframe_2308/adc_test.v +72 -0
- snapshots/jotego_jtcores_pr1270/modules/jtframe/syn/jtframe_2308/makefile +63 -0
- snapshots/jotego_jtcores_pr1270/modules/jtframe/syn/jtframe_2308/set_pins.tcl +57 -0
- snapshots/jotego_jtcores_pr1270/modules/jtframe/syn/jtframe_2308/source.qip +3 -0
- snapshots/jotego_jtcores_pr1270/modules/jtframe/target/mist/cfg/common.yaml +49 -0
- snapshots/jotego_jtcores_pr1270/modules/jtframe/target/mist/cfg/files.yaml +11 -0
- snapshots/jotego_jtcores_pr1270/modules/jtframe/target/mist/cfg/sim.yaml +18 -0
- snapshots/jotego_jtcores_pr1270/modules/jtframe/target/mist/cfgstr +19 -0
- snapshots/jotego_jtcores_pr1270/modules/jtframe/target/mist/hdl/data_io.v +572 -0
- snapshots/jotego_jtcores_pr1270/modules/jtframe/target/mist/hdl/i2c_master.v +111 -0
- snapshots/jotego_jtcores_pr1270/modules/jtframe/target/mist/hdl/i2s.v +70 -0
- snapshots/jotego_jtcores_pr1270/modules/jtframe/target/mist/hdl/jtframe_mist.sv +534 -0
- snapshots/jotego_jtcores_pr1270/modules/jtframe/target/mist/hdl/jtframe_mist_base.v +612 -0
- snapshots/jotego_jtcores_pr1270/modules/jtframe/target/mist/hdl/jtframe_mist_clocks.v +119 -0
- snapshots/jotego_jtcores_pr1270/modules/jtframe/target/mist/hdl/jtframe_mist_top.sv +642 -0
- snapshots/jotego_jtcores_pr1270/modules/jtframe/target/mist/hdl/jtframe_mist_video.v +324 -0
- snapshots/jotego_jtcores_pr1270/modules/jtframe/target/mist/hdl/osd.sv +411 -0
- snapshots/jotego_jtcores_pr1270/modules/jtframe/target/mist/hdl/pll6000/jtframe_pll6000.ppf +10 -0
- snapshots/jotego_jtcores_pr1270/modules/jtframe/target/mist/hdl/pll6000/jtframe_pll6000.qip +5 -0
- snapshots/jotego_jtcores_pr1270/modules/jtframe/target/mist/hdl/pll6000/jtframe_pll6000.v +309 -0
- snapshots/jotego_jtcores_pr1270/modules/jtframe/target/mist/hdl/pll6000/jtframe_pll6000_bb.v +199 -0
- snapshots/jotego_jtcores_pr1270/modules/jtframe/target/mist/hdl/pll6000/jtframe_pll6144.qip +0 -0
- snapshots/jotego_jtcores_pr1270/modules/jtframe/target/mist/hdl/pll6000/jtframe_pll6293.qip +0 -0
- snapshots/jotego_jtcores_pr1270/modules/jtframe/target/mist/hdl/pll6000/jtframe_pll6671.qip +0 -0
- snapshots/jotego_jtcores_pr1270/modules/jtframe/target/mist/hdl/pll6000/jtframe_pllgame96.qip +0 -0
- snapshots/jotego_jtcores_pr1270/modules/jtframe/target/mist/hdl/pll6144/jtframe_pll6144.ppf +10 -0
- snapshots/jotego_jtcores_pr1270/modules/jtframe/target/mist/hdl/pll6144/jtframe_pll6144.qip +5 -0
.gitattributes
CHANGED
|
@@ -806,3 +806,19 @@ Repos/HWE/agents/Lingxi/docs/Lingxi[[:space:]]v1.5[[:space:]]Technical[[:space:]
|
|
| 806 |
Repos/HWE/agents/Lingxi/docs/Lingxi[[:space:]]v2.0[[:space:]]Technical[[:space:]]Report[[:space:]]2026.pdf filter=lfs diff=lfs merge=lfs -text
|
| 807 |
Repos/HWE/agents/Lingxi/imgs/overview_fig.pdf filter=lfs diff=lfs merge=lfs -text
|
| 808 |
patches/esa-tu-darmstadt_tapasco_pr105.patch filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 806 |
Repos/HWE/agents/Lingxi/docs/Lingxi[[:space:]]v2.0[[:space:]]Technical[[:space:]]Report[[:space:]]2026.pdf filter=lfs diff=lfs merge=lfs -text
|
| 807 |
Repos/HWE/agents/Lingxi/imgs/overview_fig.pdf filter=lfs diff=lfs merge=lfs -text
|
| 808 |
patches/esa-tu-darmstadt_tapasco_pr105.patch filter=lfs diff=lfs merge=lfs -text
|
| 809 |
+
snapshots/jotego_jtcores_pr854/cores/aliens/doc/051937_schematics.pdf filter=lfs diff=lfs merge=lfs -text
|
| 810 |
+
snapshots/jotego_jtcores_pr854/cores/aliens/doc/051960_schematics.pdf filter=lfs diff=lfs merge=lfs -text
|
| 811 |
+
snapshots/jotego_jtcores_pr854/cores/aliens/doc/052591/k052591_schematics.pdf filter=lfs diff=lfs merge=lfs -text
|
| 812 |
+
snapshots/jotego_jtcores_pr854/cores/aliens/doc/k051962_schematics.pdf filter=lfs diff=lfs merge=lfs -text
|
| 813 |
+
snapshots/jotego_jtcores_pr854/cores/aliens/doc/k052109_schematics.pdf filter=lfs diff=lfs merge=lfs -text
|
| 814 |
+
snapshots/jotego_jtcores_pr854/cores/contra/doc/007121.pdf filter=lfs diff=lfs merge=lfs -text
|
| 815 |
+
snapshots/jotego_jtcores_pr854/cores/pinpon/doc/Konami's[[:space:]]Ping[[:space:]]Pong[[:space:]]Report.pdf filter=lfs diff=lfs merge=lfs -text
|
| 816 |
+
snapshots/jotego_jtcores_pr854/cores/s16b/doc/315-5195_schematics.pdf filter=lfs diff=lfs merge=lfs -text
|
| 817 |
+
snapshots/jotego_jtcores_pr854/cores/simson/doc/053251.pdf filter=lfs diff=lfs merge=lfs -text
|
| 818 |
+
snapshots/jotego_jtcores_pr854/cores/simson/doc/k053260_schematics.PDF filter=lfs diff=lfs merge=lfs -text
|
| 819 |
+
snapshots/jotego_jtcores_pr854/doc/articulo.odt filter=lfs diff=lfs merge=lfs -text
|
| 820 |
+
snapshots/jotego_jtcores_pr854/doc/dd2/Double[[:space:]]Dragon[[:space:]]2[[:space:]]pcb.m4a filter=lfs diff=lfs merge=lfs -text
|
| 821 |
+
snapshots/jotego_jtcores_pr854/doc/mame.xml filter=lfs diff=lfs merge=lfs -text
|
| 822 |
+
snapshots/jotego_jtcores_pr854/modules/jtframe/asm/z80/tiny_basic_instructions.pdf filter=lfs diff=lfs merge=lfs -text
|
| 823 |
+
snapshots/jotego_jtcores_pr854/modules/jtframe/doc/93c06.pdf filter=lfs diff=lfs merge=lfs -text
|
| 824 |
+
snapshots/jotego_jtcores_pr854/modules/jtframe/doc/T48[[:space:]]Integration[[:space:]]Manual.pdf filter=lfs diff=lfs merge=lfs -text
|
snapshots/jotego_jtcores_pr1270/modules/jtframe/src/jtutil/cmd/mra.go
ADDED
|
@@ -0,0 +1,252 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/* This file is part of JTCORES.
|
| 2 |
+
JTFRAME program is free software: you can redistribute it and/or modify
|
| 3 |
+
it under the terms of the GNU General Public License as published by
|
| 4 |
+
the Free Software Foundation, either version 3 of the License, or
|
| 5 |
+
(at your option) any later version.
|
| 6 |
+
|
| 7 |
+
JTFRAME program is distributed in the hope that it will be useful,
|
| 8 |
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
| 9 |
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
| 10 |
+
GNU General Public License for more details.
|
| 11 |
+
|
| 12 |
+
You should have received a copy of the GNU General Public License
|
| 13 |
+
along with JTFRAME. If not, see <http://www.gnu.org/licenses/>.
|
| 14 |
+
|
| 15 |
+
Author: Jose Tejada Gomez. Twitter: @topapate
|
| 16 |
+
Date: 4-1-2025 */
|
| 17 |
+
|
| 18 |
+
package cmd
|
| 19 |
+
|
| 20 |
+
import (
|
| 21 |
+
"encoding/xml"
|
| 22 |
+
"fmt"
|
| 23 |
+
"os"
|
| 24 |
+
"path/filepath"
|
| 25 |
+
"slices"
|
| 26 |
+
"strings"
|
| 27 |
+
|
| 28 |
+
"github.com/spf13/cobra"
|
| 29 |
+
)
|
| 30 |
+
|
| 31 |
+
var mra_args struct{
|
| 32 |
+
zip, core, main_only *bool
|
| 33 |
+
}
|
| 34 |
+
|
| 35 |
+
// mraCmd represents the mra command
|
| 36 |
+
var mraCmd = &cobra.Command{
|
| 37 |
+
Use: "mra",
|
| 38 |
+
Short: "MRA inspection utilities",
|
| 39 |
+
Long: `List zip files used in JTBIN's .mra files`,
|
| 40 |
+
Run: runMRA,
|
| 41 |
+
}
|
| 42 |
+
|
| 43 |
+
func init() {
|
| 44 |
+
rootCmd.AddCommand(mraCmd)
|
| 45 |
+
|
| 46 |
+
mra_args.zip = mraCmd.Flags().BoolP("zip", "z", false, "Shows all zip files used in MRA files")
|
| 47 |
+
mra_args.core = mraCmd.Flags().BoolP("core", "c", false, "Shows games supported by each core")
|
| 48 |
+
mra_args.main_only = mraCmd.Flags().BoolP("main-only", "m", false, "Parse only the main games")
|
| 49 |
+
}
|
| 50 |
+
|
| 51 |
+
func runMRA(cmd *cobra.Command, args []string) {
|
| 52 |
+
if( *mra_args.core && *mra_args.zip) { list_cores(true); return}
|
| 53 |
+
if( *mra_args.zip ) { list_zip(); return }
|
| 54 |
+
if( *mra_args.core ) { list_cores(false); return }
|
| 55 |
+
cmd.Help()
|
| 56 |
+
}
|
| 57 |
+
|
| 58 |
+
func list_zip() {
|
| 59 |
+
zipuse := make(map[string]bool)
|
| 60 |
+
|
| 61 |
+
get_mradata := func(fname string, fi os.DirEntry, err error) error {
|
| 62 |
+
var game MRA
|
| 63 |
+
readin_mra( fname, fi, &game, err )
|
| 64 |
+
if len(game.Rom)==0 { return nil }
|
| 65 |
+
names := strings.Split(game.Rom[0].Zip, "|")
|
| 66 |
+
if len(names) == 0 {
|
| 67 |
+
return nil
|
| 68 |
+
}
|
| 69 |
+
if len(names)>1 && verbose {
|
| 70 |
+
fmt.Println(names)
|
| 71 |
+
}
|
| 72 |
+
last := len(names)-1
|
| 73 |
+
merged := names[last]
|
| 74 |
+
if merged=="qsound.zip" && len(names)==2 {
|
| 75 |
+
setname := names[last-1]
|
| 76 |
+
zipuse[setname] = true
|
| 77 |
+
}
|
| 78 |
+
zipuse[merged] = true
|
| 79 |
+
return nil
|
| 80 |
+
}
|
| 81 |
+
e := filepath.WalkDir(filepath.Join(os.Getenv("JTBIN"), "mra"), get_mradata)
|
| 82 |
+
if e != nil {
|
| 83 |
+
fmt.Println(e)
|
| 84 |
+
os.Exit(1)
|
| 85 |
+
}
|
| 86 |
+
first := true
|
| 87 |
+
for each, _ := range zipuse {
|
| 88 |
+
if !first {
|
| 89 |
+
fmt.Print(" ")
|
| 90 |
+
}
|
| 91 |
+
fmt.Print(each)
|
| 92 |
+
first = false
|
| 93 |
+
}
|
| 94 |
+
}
|
| 95 |
+
|
| 96 |
+
func readin_mra(fname string, fi os.DirEntry, game *MRA, err error) (error) {
|
| 97 |
+
if !strings.HasSuffix(fname,".mra") { return nil }
|
| 98 |
+
if err != nil {
|
| 99 |
+
fmt.Println(err)
|
| 100 |
+
return nil
|
| 101 |
+
}
|
| 102 |
+
if fi.IsDir() {
|
| 103 |
+
return nil
|
| 104 |
+
}
|
| 105 |
+
// get the information
|
| 106 |
+
buf, e := os.ReadFile(fname)
|
| 107 |
+
if e != nil {
|
| 108 |
+
return e
|
| 109 |
+
}
|
| 110 |
+
xml.Unmarshal(buf, game)
|
| 111 |
+
if game.Name=="" {
|
| 112 |
+
fmt.Printf("Warning: no game Name for file %s\n",fname)
|
| 113 |
+
return nil
|
| 114 |
+
}
|
| 115 |
+
return err
|
| 116 |
+
}
|
| 117 |
+
|
| 118 |
+
type game_info struct {
|
| 119 |
+
name, mame_set, zip string
|
| 120 |
+
}
|
| 121 |
+
|
| 122 |
+
type jtcores map[string][]game_info
|
| 123 |
+
|
| 124 |
+
func cmp_games( a, b game_info) int {
|
| 125 |
+
return strings.Compare(a.name,b.name)
|
| 126 |
+
}
|
| 127 |
+
|
| 128 |
+
func list_cores(include_zip bool) {
|
| 129 |
+
const delim = "|"
|
| 130 |
+
games, e := get_coregames(delim)
|
| 131 |
+
if e != nil {
|
| 132 |
+
fmt.Println(e)
|
| 133 |
+
os.Exit(1)
|
| 134 |
+
}
|
| 135 |
+
sorted_cores := sort_cores(games)
|
| 136 |
+
sort_games(games)
|
| 137 |
+
report_games(sorted_cores, games, include_zip)
|
| 138 |
+
}
|
| 139 |
+
|
| 140 |
+
func get_coregames(delim string) (jtcores,error) {
|
| 141 |
+
games := make(jtcores)
|
| 142 |
+
get_mradata := func(fname string, fi os.DirEntry, err error) error {
|
| 143 |
+
var game MRA
|
| 144 |
+
if is_alternative(fname) && *mra_args.main_only { return nil }
|
| 145 |
+
readin_mra( fname, fi, &game, err )
|
| 146 |
+
if game.Setname=="" { return nil }
|
| 147 |
+
list, found := games[game.Rbf]
|
| 148 |
+
if !found || list==nil {
|
| 149 |
+
list = make([]game_info,0,16)
|
| 150 |
+
}
|
| 151 |
+
info := game_info {
|
| 152 |
+
name: game.Name,
|
| 153 |
+
mame_set: game.Setname,
|
| 154 |
+
zip: strings.ReplaceAll(game.Rom[0].Zip, "|", " "),
|
| 155 |
+
}
|
| 156 |
+
games[game.Rbf]=append(list,info)
|
| 157 |
+
return nil
|
| 158 |
+
}
|
| 159 |
+
e := filepath.WalkDir(filepath.Join(os.Getenv("JTBIN"), "mra"), get_mradata)
|
| 160 |
+
if e!=nil { return nil, e }
|
| 161 |
+
return games, nil
|
| 162 |
+
}
|
| 163 |
+
|
| 164 |
+
func is_alternative(fname string) bool {
|
| 165 |
+
up2levels := filepath.Dir(filepath.Dir(fname))
|
| 166 |
+
dirname := filepath.Base(up2levels)
|
| 167 |
+
return dirname=="_alternatives"
|
| 168 |
+
}
|
| 169 |
+
|
| 170 |
+
func sort_cores(all_cores jtcores) []string {
|
| 171 |
+
sorted_names := make([]string,0,len(all_cores))
|
| 172 |
+
for name,_ := range all_cores {
|
| 173 |
+
sorted_names = append(sorted_names,name)
|
| 174 |
+
}
|
| 175 |
+
slices.Sort(sorted_names)
|
| 176 |
+
return sorted_names
|
| 177 |
+
}
|
| 178 |
+
|
| 179 |
+
func sort_games(all_games jtcores) {
|
| 180 |
+
for _, core_games := range all_games {
|
| 181 |
+
slices.SortFunc(core_games,cmp_games)
|
| 182 |
+
}
|
| 183 |
+
}
|
| 184 |
+
|
| 185 |
+
func report_games(cores []string, games jtcores, include_zip bool) {
|
| 186 |
+
game_count := 0
|
| 187 |
+
core_len, game_len, set_len, zip_len := find_longest_names(games)
|
| 188 |
+
format := make_format_string(core_len, game_len, set_len, zip_len, include_zip)
|
| 189 |
+
print_header(format, include_zip)
|
| 190 |
+
for _, corename := range cores {
|
| 191 |
+
core_games := games[corename]
|
| 192 |
+
for _,info := range core_games {
|
| 193 |
+
if include_zip {
|
| 194 |
+
fmt.Printf(format,corename[2:],info.name,info.mame_set, info.zip)
|
| 195 |
+
} else {
|
| 196 |
+
fmt.Printf(format,corename[2:],info.name,info.mame_set)
|
| 197 |
+
}
|
| 198 |
+
game_count++
|
| 199 |
+
}
|
| 200 |
+
}
|
| 201 |
+
fmt.Printf("\n%d cores, supporting %d games\n",len(cores),game_count)
|
| 202 |
+
}
|
| 203 |
+
|
| 204 |
+
func find_longest_names(all_games jtcores) (core_len, game_len, set_len, zip_len int) {
|
| 205 |
+
for corename, coregames := range all_games {
|
| 206 |
+
core_len = max_length(corename, core_len)
|
| 207 |
+
for _, info := range coregames {
|
| 208 |
+
game_len = max_length(info.name, game_len)
|
| 209 |
+
set_len = max_length(info.mame_set, set_len)
|
| 210 |
+
zip_len = max_length(info.zip, zip_len)
|
| 211 |
+
}
|
| 212 |
+
}
|
| 213 |
+
const JTPREFIX_LEN = 2
|
| 214 |
+
core_len -= JTPREFIX_LEN
|
| 215 |
+
return core_len, game_len, set_len, zip_len
|
| 216 |
+
}
|
| 217 |
+
|
| 218 |
+
func max_length(name string, previous_max int) int {
|
| 219 |
+
name_length := len(name)
|
| 220 |
+
if name_length>previous_max {
|
| 221 |
+
return name_length
|
| 222 |
+
} else {
|
| 223 |
+
return previous_max
|
| 224 |
+
}
|
| 225 |
+
}
|
| 226 |
+
|
| 227 |
+
func make_format_string(core_len, game_len, set_len, zip_len int, include_zip bool) string {
|
| 228 |
+
if include_zip {
|
| 229 |
+
return fmt.Sprintf("| %%-%ds | %%-%ds | %%-%ds | %%-%ds |\n", core_len, game_len, set_len, zip_len)
|
| 230 |
+
} else {
|
| 231 |
+
return fmt.Sprintf("| %%-%ds | %%-%ds | %%-%ds |\n", core_len, game_len, set_len)
|
| 232 |
+
}
|
| 233 |
+
}
|
| 234 |
+
|
| 235 |
+
func print_header(format string, include_zip bool) {
|
| 236 |
+
var header string
|
| 237 |
+
if include_zip {
|
| 238 |
+
header = fmt.Sprintf(format,"Core","Game", "MAME set", "ZIP files")
|
| 239 |
+
} else {
|
| 240 |
+
header = fmt.Sprintf(format,"Core","Game","MAME set")
|
| 241 |
+
}
|
| 242 |
+
dashline := make([]rune,len(header))
|
| 243 |
+
for k,_ := range dashline {
|
| 244 |
+
if header[k]=='|' || header[k]=='\n'{
|
| 245 |
+
dashline[k]=rune(header[k])
|
| 246 |
+
} else {
|
| 247 |
+
dashline[k]='-'
|
| 248 |
+
}
|
| 249 |
+
}
|
| 250 |
+
fmt.Printf(header)
|
| 251 |
+
fmt.Printf(string(dashline))
|
| 252 |
+
}
|
snapshots/jotego_jtcores_pr1270/modules/jtframe/src/jtutil/cmd/root.go
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/* This file is part of JTCORES.
|
| 2 |
+
JTFRAME program is free software: you can redistribute it and/or modify
|
| 3 |
+
it under the terms of the GNU General Public License as published by
|
| 4 |
+
the Free Software Foundation, either version 3 of the License, or
|
| 5 |
+
(at your option) any later version.
|
| 6 |
+
|
| 7 |
+
JTFRAME program is distributed in the hope that it will be useful,
|
| 8 |
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
| 9 |
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
| 10 |
+
GNU General Public License for more details.
|
| 11 |
+
|
| 12 |
+
You should have received a copy of the GNU General Public License
|
| 13 |
+
along with JTFRAME. If not, see <http://www.gnu.org/licenses/>.
|
| 14 |
+
|
| 15 |
+
Author: Jose Tejada Gomez. Twitter: @topapate
|
| 16 |
+
Date: 4-1-2025 */
|
| 17 |
+
|
| 18 |
+
package cmd
|
| 19 |
+
|
| 20 |
+
import (
|
| 21 |
+
"fmt"
|
| 22 |
+
"os"
|
| 23 |
+
|
| 24 |
+
"jtutil/cmd/wav"
|
| 25 |
+
"github.com/spf13/cobra"
|
| 26 |
+
)
|
| 27 |
+
|
| 28 |
+
var verbose bool
|
| 29 |
+
|
| 30 |
+
// rootCmd represents the base command when called without any subcommands
|
| 31 |
+
var rootCmd = &cobra.Command{
|
| 32 |
+
Use: "jtutil",
|
| 33 |
+
}
|
| 34 |
+
|
| 35 |
+
func Execute() {
|
| 36 |
+
err := rootCmd.Execute()
|
| 37 |
+
if err != nil {
|
| 38 |
+
os.Exit(1)
|
| 39 |
+
}
|
| 40 |
+
}
|
| 41 |
+
|
| 42 |
+
func init() {
|
| 43 |
+
rootCmd.PersistentFlags().BoolVarP(&verbose, "verbose", "v", false, "Verbose")
|
| 44 |
+
add_wav_cmd()
|
| 45 |
+
}
|
| 46 |
+
|
| 47 |
+
func add_wav_cmd() {
|
| 48 |
+
var wavCmd = &cobra.Command{
|
| 49 |
+
Use: "wav [test.vcd]",
|
| 50 |
+
Short: "Creates a WAV file from the given VCD dump",
|
| 51 |
+
Run: wav.RunWavCmd,
|
| 52 |
+
Args: cobra.MaximumNArgs(1),
|
| 53 |
+
}
|
| 54 |
+
wavCmd.Flags().StringP("output","o","vcd.wav","output file name")
|
| 55 |
+
wavCmd.Flags().StringP("signal","s","","signal name")
|
| 56 |
+
wavCmd.Flags().BoolP ("skip","k",false,"skip initial silence in input file")
|
| 57 |
+
rootCmd.AddCommand(wavCmd)
|
| 58 |
+
}
|
| 59 |
+
|
| 60 |
+
func must(e... error) {
|
| 61 |
+
if e==nil || len(e)==0 || e[0]==nil { return }
|
| 62 |
+
for _, each_error := range e {
|
| 63 |
+
fmt.Println(each_error)
|
| 64 |
+
}
|
| 65 |
+
os.Exit(1)
|
| 66 |
+
}
|
snapshots/jotego_jtcores_pr1270/modules/jtframe/src/jtutil/cmd/sdram.go
ADDED
|
@@ -0,0 +1,281 @@
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/* This file is part of JTCORES.
|
| 2 |
+
JTFRAME program is free software: you can redistribute it and/or modify
|
| 3 |
+
it under the terms of the GNU General Public License as published by
|
| 4 |
+
the Free Software Foundation, either version 3 of the License, or
|
| 5 |
+
(at your option) any later version.
|
| 6 |
+
|
| 7 |
+
JTFRAME program is distributed in the hope that it will be useful,
|
| 8 |
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
| 9 |
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
| 10 |
+
GNU General Public License for more details.
|
| 11 |
+
|
| 12 |
+
You should have received a copy of the GNU General Public License
|
| 13 |
+
along with JTFRAME. If not, see <http://www.gnu.org/licenses/>.
|
| 14 |
+
|
| 15 |
+
Author: Jose Tejada Gomez. Twitter: @topapate
|
| 16 |
+
Date: 4-1-2025 */
|
| 17 |
+
|
| 18 |
+
package cmd
|
| 19 |
+
|
| 20 |
+
import (
|
| 21 |
+
"fmt"
|
| 22 |
+
|
| 23 |
+
"os"
|
| 24 |
+
"strings"
|
| 25 |
+
"path/filepath"
|
| 26 |
+
"github.com/spf13/cobra"
|
| 27 |
+
"jotego/jtframe/macros"
|
| 28 |
+
"jotego/jtframe/mra"
|
| 29 |
+
)
|
| 30 |
+
|
| 31 |
+
// sdramCmd represents the sdram command
|
| 32 |
+
var sdramCmd = &cobra.Command{
|
| 33 |
+
Use: "sdram [game-name]",
|
| 34 |
+
Short: "Convert .rom files to sdram files for quick simulation",
|
| 35 |
+
Long: `Convert .rom files to sdram files for quick simulation
|
| 36 |
+
|
| 37 |
+
After you create the .rom files using jtframe mra, you can generate
|
| 38 |
+
the sdram*.bin simulation files without having to run a download simulation by
|
| 39 |
+
calling jtframe sdram.
|
| 40 |
+
|
| 41 |
+
jtframe sdram must be called from within a simulation folder, such as ver/game.
|
| 42 |
+
If the simulation folder is the ROM set name, that will be used. If the folder
|
| 43 |
+
is just "game", then the set name must be provided in the command line.
|
| 44 |
+
|
| 45 |
+
jtframe sdram will split the .rom file in the right number of sdram*bin files by
|
| 46 |
+
inspecting the definitions of JTFRAME_BA?_START, JTFRAME_PROM_START and
|
| 47 |
+
JTFRAME_HEADER.
|
| 48 |
+
|
| 49 |
+
jtframe sdram will also link a rom.bin file to the .rom file used. If rom.bin
|
| 50 |
+
already existed, it will be deleted and re-created as a link.
|
| 51 |
+
|
| 52 |
+
If the core uses the header for SDRAM bank assignment, special care
|
| 53 |
+
must be taken for the PROM data as JTFRAME_PROM_START will not be defined. This
|
| 54 |
+
utility will create a file for each ROM region after bank 3, so the core can
|
| 55 |
+
directly load these files in simulation. You can also force the PROM load in
|
| 56 |
+
simulation for these cores by setting the SIM_LOAD_PROM macro.
|
| 57 |
+
|
| 58 |
+
The result will only be correct for cores that do not transform download data on
|
| 59 |
+
the fly.
|
| 60 |
+
`,
|
| 61 |
+
Run: run_sdram,
|
| 62 |
+
Args: cobra.MaximumNArgs(1),
|
| 63 |
+
}
|
| 64 |
+
|
| 65 |
+
func init() {
|
| 66 |
+
rootCmd.AddCommand(sdramCmd)
|
| 67 |
+
}
|
| 68 |
+
|
| 69 |
+
func run_sdram(cmd *cobra.Command, args []string) {
|
| 70 |
+
var game string
|
| 71 |
+
|
| 72 |
+
if len(args)!=0 {
|
| 73 |
+
game=args[0]
|
| 74 |
+
} else {
|
| 75 |
+
var e error
|
| 76 |
+
game, e = derive_game_from_wd()
|
| 77 |
+
must(e)
|
| 78 |
+
}
|
| 79 |
+
|
| 80 |
+
must(validate_wd())
|
| 81 |
+
core := derive_core_from_wd()
|
| 82 |
+
macros.MakeMacros( core, "mist" )
|
| 83 |
+
e := extract_sdram(core,game)
|
| 84 |
+
if e!=nil {
|
| 85 |
+
fmt.Println(e.Error())
|
| 86 |
+
os.Exit(1)
|
| 87 |
+
}
|
| 88 |
+
make_symlink(game)
|
| 89 |
+
}
|
| 90 |
+
|
| 91 |
+
func derive_game_from_wd() (string,error) {
|
| 92 |
+
wd, e := os.Getwd()
|
| 93 |
+
if e != nil { return "", e }
|
| 94 |
+
game := filepath.Base(wd)
|
| 95 |
+
if game=="game" {
|
| 96 |
+
return "",fmt.Errorf("Cannot derive ROM set name from current folder. Use jtutil sdram <game> instead.")
|
| 97 |
+
}
|
| 98 |
+
return game,nil
|
| 99 |
+
}
|
| 100 |
+
|
| 101 |
+
func validate_wd() (error) {
|
| 102 |
+
wd, e := os.Getwd()
|
| 103 |
+
if e != nil { return e }
|
| 104 |
+
wd = filepath.Join(wd,"..")
|
| 105 |
+
if filepath.Base(wd)!="ver" {
|
| 106 |
+
return fmt.Errorf("jtutil sdram must be called from a ver/game folder")
|
| 107 |
+
}
|
| 108 |
+
return nil
|
| 109 |
+
}
|
| 110 |
+
|
| 111 |
+
func derive_core_from_wd() string {
|
| 112 |
+
wd,_ := os.Getwd()
|
| 113 |
+
return filepath.Base(filepath.Join(wd,"../.."))
|
| 114 |
+
}
|
| 115 |
+
|
| 116 |
+
func must_env( env string ) string {
|
| 117 |
+
v, e := os.LookupEnv(env)
|
| 118 |
+
if !e {
|
| 119 |
+
fmt.Println(env,"is not defined in the environment.")
|
| 120 |
+
os.Exit(1)
|
| 121 |
+
}
|
| 122 |
+
return v
|
| 123 |
+
}
|
| 124 |
+
|
| 125 |
+
func swap_bytes( rom []byte, start int ) {
|
| 126 |
+
for k:=start;k<len(rom);k+=2 {
|
| 127 |
+
aux := rom[k]
|
| 128 |
+
rom[k] = rom[k+1]
|
| 129 |
+
rom[k+1] = aux
|
| 130 |
+
}
|
| 131 |
+
}
|
| 132 |
+
|
| 133 |
+
func read_rom( game string ) []byte {
|
| 134 |
+
rom, e := os.ReadFile( filepath.Join(must_env("JTROOT"),"rom",game+".rom") )
|
| 135 |
+
must(e)
|
| 136 |
+
if (len(rom)&1) != 0 {
|
| 137 |
+
fmt.Println("The ROM length must be even")
|
| 138 |
+
os.Exit(1)
|
| 139 |
+
}
|
| 140 |
+
// swap the bytes so the sdram.bin files get written correctly as 16-bit words
|
| 141 |
+
swap_bytes(rom,0)
|
| 142 |
+
return rom
|
| 143 |
+
}
|
| 144 |
+
|
| 145 |
+
|
| 146 |
+
func extract_sdram( core, game string ) error {
|
| 147 |
+
const EIGHT_MB=8*1024*1024
|
| 148 |
+
rom := read_rom(game)
|
| 149 |
+
|
| 150 |
+
mra_cfg, e := mra.ParseTomlFile(core)
|
| 151 |
+
reg_cnt := len(mra_cfg.Header.Offset.Regions)
|
| 152 |
+
hinfo := mra_cfg.Header.Offset
|
| 153 |
+
if e!=nil { return e }
|
| 154 |
+
offsets,reg:= bankOffset(reg_cnt,hinfo,rom)
|
| 155 |
+
|
| 156 |
+
header := macros.GetInt("JTFRAME_HEADER")
|
| 157 |
+
prom_start := offsets[4]
|
| 158 |
+
nx_start, e := dump("sdram_bank0.bin",rom,header,offsets[1], prom_start, EIGHT_MB)
|
| 159 |
+
if e!=nil { return fmt.Errorf("%w for bank 0",e) }
|
| 160 |
+
if nx_start<0 {
|
| 161 |
+
os.Remove("sdram_bank1.bin")
|
| 162 |
+
os.Remove("sdram_bank2.bin")
|
| 163 |
+
os.Remove("sdram_bank3.bin")
|
| 164 |
+
return nil
|
| 165 |
+
}
|
| 166 |
+
nx_start, e = dump("sdram_bank1.bin",rom,nx_start,offsets[2], prom_start, EIGHT_MB)
|
| 167 |
+
if e!=nil { return fmt.Errorf("%w for bank 1",e) }
|
| 168 |
+
if nx_start<0 {
|
| 169 |
+
os.Remove("sdram_bank2.bin")
|
| 170 |
+
os.Remove("sdram_bank3.bin")
|
| 171 |
+
return nil
|
| 172 |
+
}
|
| 173 |
+
nx_start, e = dump("sdram_bank2.bin",rom,nx_start,offsets[3], prom_start, EIGHT_MB)
|
| 174 |
+
if e!=nil { return fmt.Errorf("%w for bank 2",e) }
|
| 175 |
+
if nx_start<0 {
|
| 176 |
+
os.Remove("sdram_bank3.bin")
|
| 177 |
+
fmt.Println("Skippin bank3")
|
| 178 |
+
return nil
|
| 179 |
+
}
|
| 180 |
+
nx_start, e = dump("sdram_bank3.bin",rom,nx_start,0,prom_start, EIGHT_MB)
|
| 181 |
+
if e!=nil { return fmt.Errorf("%w for bank 3",e) }
|
| 182 |
+
// extra regions (read with prom_we set)
|
| 183 |
+
if len(reg)>4 { // undo the swap that was needed for the SDRAM part of the ROM file
|
| 184 |
+
swap_bytes(rom,offsets[4])
|
| 185 |
+
}
|
| 186 |
+
for k:=4; k<len(reg);k++ {
|
| 187 |
+
nx := 0
|
| 188 |
+
if k+1 < len(reg) {
|
| 189 |
+
nx = offsets[k+1]
|
| 190 |
+
}
|
| 191 |
+
_, e = dump(reg[k],rom,offsets[k],nx,len(rom),0)
|
| 192 |
+
if e!=nil { return e }
|
| 193 |
+
}
|
| 194 |
+
return nil
|
| 195 |
+
}
|
| 196 |
+
|
| 197 |
+
func bankOffset( reg_cnt int, hinfo mra.HeaderOffset, rom []byte ) ([]int, []string) {
|
| 198 |
+
header := macros.GetInt("JTFRAME_HEADER")
|
| 199 |
+
|
| 200 |
+
if reg_cnt < 5 {
|
| 201 |
+
reg_cnt=5
|
| 202 |
+
}
|
| 203 |
+
offsets := make([]int,reg_cnt)
|
| 204 |
+
// Default values from macros (if defined)
|
| 205 |
+
offsets[1] = macros.GetInt("JTFRAME_BA1_START")+header
|
| 206 |
+
offsets[2] = macros.GetInt("JTFRAME_BA2_START")+header
|
| 207 |
+
offsets[3] = macros.GetInt("JTFRAME_BA3_START")+header
|
| 208 |
+
offsets[4] = macros.GetInt("JTFRAME_PROM_START")+header
|
| 209 |
+
for k, _ := range offsets {
|
| 210 |
+
if offsets[k] <= header {
|
| 211 |
+
offsets[k] = len(rom)
|
| 212 |
+
}
|
| 213 |
+
}
|
| 214 |
+
// final values from header (if defined)
|
| 215 |
+
for k:=1; k<len(hinfo.Regions); k++ {
|
| 216 |
+
var pos int
|
| 217 |
+
pos = int(rom[hinfo.Start+(k<<1)])<<8
|
| 218 |
+
pos |= int(rom[hinfo.Start+(k<<1)+1])
|
| 219 |
+
pos <<= hinfo.Bits
|
| 220 |
+
offsets[k]=pos+header
|
| 221 |
+
if verbose {
|
| 222 |
+
fmt.Printf("%-4d %-20s %X\n",k,hinfo.Regions[k], offsets[k])
|
| 223 |
+
}
|
| 224 |
+
}
|
| 225 |
+
if verbose {
|
| 226 |
+
fmt.Println("Offsets")
|
| 227 |
+
for k:=1; k<len(offsets); k++ {
|
| 228 |
+
fmt.Printf("%d %X\n",k,offsets[k])
|
| 229 |
+
}
|
| 230 |
+
fmt.Println()
|
| 231 |
+
}
|
| 232 |
+
return offsets,hinfo.Regions
|
| 233 |
+
}
|
| 234 |
+
|
| 235 |
+
func dump( name string, rom []byte, p0, p1, lim, fill int) (int,error) {
|
| 236 |
+
if verbose {
|
| 237 |
+
fmt.Printf("%10s p0=%08X p1=%08X lim=%08X fill=%08X\n",name,p0,p1,lim,fill)
|
| 238 |
+
}
|
| 239 |
+
if p1<=0 { p1 = lim }
|
| 240 |
+
if verbose { fmt.Printf("%s %X -> %X\n",name,p0,p1) }
|
| 241 |
+
if p1<p0 { return 0,fmt.Errorf("start offset was beyond end offset") }
|
| 242 |
+
if p1<=0 { return p0, nil }
|
| 243 |
+
if p1>len(rom) {
|
| 244 |
+
return 0,fmt.Errorf("ROM file is too short to produce file: $%X > $%X",
|
| 245 |
+
p1, len(rom))
|
| 246 |
+
}
|
| 247 |
+
if( p1==p0 && fill==0 ) {
|
| 248 |
+
e := os.Remove(name)
|
| 249 |
+
if e!=nil {
|
| 250 |
+
return 0,e
|
| 251 |
+
}
|
| 252 |
+
fmt.Println("Removed file",name)
|
| 253 |
+
return p1,nil
|
| 254 |
+
}
|
| 255 |
+
if e := os.WriteFile( name, rom[p0:p1],0664 ); e!=nil { return 0,e }
|
| 256 |
+
// complement up to 8MB
|
| 257 |
+
sz := p1-p0
|
| 258 |
+
if sz >= fill { return p1,nil }
|
| 259 |
+
f, e := os.OpenFile(name,os.O_APPEND|os.O_WRONLY,0664); if e!=nil { return 0,e }
|
| 260 |
+
defer f.Close()
|
| 261 |
+
blank := make([]byte,fill-sz)
|
| 262 |
+
_, e = f.Write(blank); if e!=nil { return 0,e }
|
| 263 |
+
if verbose {
|
| 264 |
+
fmt.Printf("%s done. Next starts at %x\n",name,p1)
|
| 265 |
+
}
|
| 266 |
+
return p1,nil
|
| 267 |
+
}
|
| 268 |
+
|
| 269 |
+
func make_symlink( game string ) {
|
| 270 |
+
// Link ROM files
|
| 271 |
+
src := filepath.Join(must_env("JTROOT"),"rom",game+".rom")
|
| 272 |
+
os.Remove("rom.bin")
|
| 273 |
+
os.Symlink(src,"rom.bin")
|
| 274 |
+
// Link NVRAM files
|
| 275 |
+
src = filepath.Join(must_env("JTROOT"),"rom",strings.ToUpper(game+".RAM"))
|
| 276 |
+
f, e := os.Open(src)
|
| 277 |
+
defer f.Close()
|
| 278 |
+
if e!=nil { return } // No RAM file
|
| 279 |
+
os.Remove("nvram.bin")
|
| 280 |
+
os.Symlink(src,"nvram.bin")
|
| 281 |
+
}
|
snapshots/jotego_jtcores_pr1270/modules/jtframe/src/jtutil/cmd/split16.go
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/* This file is part of JTCORES.
|
| 2 |
+
JTFRAME program is free software: you can redistribute it and/or modify
|
| 3 |
+
it under the terms of the GNU General Public License as published by
|
| 4 |
+
the Free Software Foundation, either version 3 of the License, or
|
| 5 |
+
(at your option) any later version.
|
| 6 |
+
|
| 7 |
+
JTFRAME program is distributed in the hope that it will be useful,
|
| 8 |
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
| 9 |
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
| 10 |
+
GNU General Public License for more details.
|
| 11 |
+
|
| 12 |
+
You should have received a copy of the GNU General Public License
|
| 13 |
+
along with JTFRAME. If not, see <http://www.gnu.org/licenses/>.
|
| 14 |
+
|
| 15 |
+
Author: Jose Tejada Gomez. Twitter: @topapate
|
| 16 |
+
Date: 4-1-2025 */
|
| 17 |
+
|
| 18 |
+
package cmd
|
| 19 |
+
|
| 20 |
+
import (
|
| 21 |
+
"fmt"
|
| 22 |
+
"os"
|
| 23 |
+
"strings"
|
| 24 |
+
|
| 25 |
+
"github.com/spf13/cobra"
|
| 26 |
+
)
|
| 27 |
+
|
| 28 |
+
var split16_swap *bool
|
| 29 |
+
|
| 30 |
+
// split16Cmd represents the split16 command
|
| 31 |
+
var split16Cmd = &cobra.Command{
|
| 32 |
+
Use: "split16",
|
| 33 |
+
Short: "Splits a file in two halves. Intended for 16-bit ROM simulation",
|
| 34 |
+
Long: `16-bit memories are normally implemented as two 8-bit memories.
|
| 35 |
+
In order to load a default value from a file, you need to split the file in
|
| 36 |
+
two halves. The new files add _lo and _hi to the name`,
|
| 37 |
+
Args: cobra.MinimumNArgs(1),
|
| 38 |
+
Run: func(cmd *cobra.Command, args []string) {
|
| 39 |
+
for _, each := range args {
|
| 40 |
+
b, e := os.ReadFile( each )
|
| 41 |
+
if e != nil {
|
| 42 |
+
fmt.Println(e)
|
| 43 |
+
continue
|
| 44 |
+
}
|
| 45 |
+
order := 0
|
| 46 |
+
if *split16_swap { order = 1 }
|
| 47 |
+
split16_dump( each, b, order, "_lo")
|
| 48 |
+
split16_dump( each, b, 1-order, "_hi")
|
| 49 |
+
}
|
| 50 |
+
},
|
| 51 |
+
}
|
| 52 |
+
|
| 53 |
+
func split16_dump( fname string, b []byte, order int, suffix string ) {
|
| 54 |
+
if k:=strings.LastIndex(fname,"."); k>0 {
|
| 55 |
+
fname = fname[0:k]+suffix+fname[k:]
|
| 56 |
+
} else {
|
| 57 |
+
fname += suffix
|
| 58 |
+
}
|
| 59 |
+
f, e := os.Create(fname)
|
| 60 |
+
if e!=nil {
|
| 61 |
+
fmt.Println(e)
|
| 62 |
+
return
|
| 63 |
+
}
|
| 64 |
+
bout := make([]byte,len(b)/2)
|
| 65 |
+
j:=0
|
| 66 |
+
for k:=order; k<len(b); k+=2 {
|
| 67 |
+
bout[j] = b[k]
|
| 68 |
+
j++
|
| 69 |
+
}
|
| 70 |
+
f.Write(bout)
|
| 71 |
+
f.Close()
|
| 72 |
+
}
|
| 73 |
+
|
| 74 |
+
func init() {
|
| 75 |
+
rootCmd.AddCommand(split16Cmd)
|
| 76 |
+
split16_swap = split16Cmd.Flags().BoolP("swap", "s", false, "swaps lo and hi files")
|
| 77 |
+
}
|
snapshots/jotego_jtcores_pr1270/modules/jtframe/src/jtutil/cmd/tilemap.go
ADDED
|
@@ -0,0 +1,278 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
it under the terms of the GNU General Public License as published by
|
| 4 |
+
the Free Software Foundation, either version 3 of the License, or
|
| 5 |
+
(at your option) any later version.
|
| 6 |
+
|
| 7 |
+
JTFRAME program is distributed in the hope that it will be useful,
|
| 8 |
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
| 9 |
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
| 10 |
+
GNU General Public License for more details.
|
| 11 |
+
|
| 12 |
+
You should have received a copy of the GNU General Public License
|
| 13 |
+
along with JTFRAME. If not, see <http://www.gnu.org/licenses/>.
|
| 14 |
+
|
| 15 |
+
Author: Jose Tejada Gomez. Twitter: @topapate
|
| 16 |
+
Date: 4-1-2025 */
|
| 17 |
+
|
| 18 |
+
package cmd
|
| 19 |
+
|
| 20 |
+
import (
|
| 21 |
+
"fmt"
|
| 22 |
+
"crypto/sha1"
|
| 23 |
+
"encoding/hex"
|
| 24 |
+
"image"
|
| 25 |
+
"image/color"
|
| 26 |
+
"image/png"
|
| 27 |
+
"math"
|
| 28 |
+
"os"
|
| 29 |
+
|
| 30 |
+
"github.com/spf13/cobra"
|
| 31 |
+
)
|
| 32 |
+
|
| 33 |
+
var tilemap_args struct{
|
| 34 |
+
name string
|
| 35 |
+
array bool
|
| 36 |
+
wround bool
|
| 37 |
+
}
|
| 38 |
+
|
| 39 |
+
// tilemapCmd represents the tilemap command
|
| 40 |
+
var tilemapCmd = &cobra.Command{
|
| 41 |
+
Use: "tilemap",
|
| 42 |
+
Short: "Converts a PNG image to a tile map",
|
| 43 |
+
Long: `Creates two output files: tilemap.hex and tiledata.hex`,
|
| 44 |
+
Args: cobra.MinimumNArgs(1),
|
| 45 |
+
Run: func(cmd *cobra.Command, args []string) {
|
| 46 |
+
png2tilemap(args[0], tilemap_args.name )
|
| 47 |
+
},
|
| 48 |
+
}
|
| 49 |
+
|
| 50 |
+
func init() {
|
| 51 |
+
rootCmd.AddCommand(tilemapCmd)
|
| 52 |
+
|
| 53 |
+
// Here you will define your flags and configuration settings.
|
| 54 |
+
|
| 55 |
+
// Cobra supports Persistent Flags which will work for this command
|
| 56 |
+
// and all subcommands, e.g.:
|
| 57 |
+
// tilemapCmd.PersistentFlags().String("foo", "", "A help for foo")
|
| 58 |
+
|
| 59 |
+
// Cobra supports local flags which will only run when this command
|
| 60 |
+
// is called directly, e.g.:
|
| 61 |
+
// tilemapCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle")
|
| 62 |
+
tilemapCmd.Flags().StringVarP( &tilemap_args.name, "name", "n", "tile", "Prefix for output file names")
|
| 63 |
+
tilemapCmd.Flags().BoolVarP( &tilemap_args.array, "array", "a", false, "Output System Verilog arrays instead of a .hex file")
|
| 64 |
+
tilemapCmd.Flags().BoolVarP( &tilemap_args.wround, "width", "w", true, "Round up map width to nearest power of 2")
|
| 65 |
+
}
|
| 66 |
+
|
| 67 |
+
func png2tilemap( fname, ofname string ) {
|
| 68 |
+
f, e := os.Open(fname)
|
| 69 |
+
if e != nil {
|
| 70 |
+
fmt.Println(e)
|
| 71 |
+
os.Exit(1)
|
| 72 |
+
}
|
| 73 |
+
defer f.Close()
|
| 74 |
+
img, e := png.Decode(f)
|
| 75 |
+
if e != nil {
|
| 76 |
+
fmt.Println(e)
|
| 77 |
+
os.Exit(1)
|
| 78 |
+
}
|
| 79 |
+
if img.Bounds().Dx() % 8 != 0 || img.Bounds().Dy()%8!=0 {
|
| 80 |
+
fmt.Println("The image width and height must be a multiple of 8")
|
| 81 |
+
os.Exit(1)
|
| 82 |
+
}
|
| 83 |
+
|
| 84 |
+
uniqueBlocks := make(map[string]image.Image)
|
| 85 |
+
blockIds := make(map[string]int)
|
| 86 |
+
tiles := make([]image.Image,0)
|
| 87 |
+
tilemap := make([]int,0)
|
| 88 |
+
id := 0
|
| 89 |
+
w := 0
|
| 90 |
+
map_width := img.Bounds().Dx()>>3
|
| 91 |
+
map_wround := int( math.Ceil(math.Log2(float64(map_width))) )
|
| 92 |
+
|
| 93 |
+
for y := 0; y < img.Bounds().Dy(); y += 8 {
|
| 94 |
+
for x := 0; x < img.Bounds().Dx(); x += 8 {
|
| 95 |
+
// Create a sub-image (block)
|
| 96 |
+
block := img.(interface {
|
| 97 |
+
SubImage(r image.Rectangle) image.Image
|
| 98 |
+
}).SubImage(image.Rect(x, y, x+8, y+8))
|
| 99 |
+
|
| 100 |
+
// Create a hash for the block
|
| 101 |
+
hash := hashImage(block)
|
| 102 |
+
// fmt.Println(x,y,hash)
|
| 103 |
+
|
| 104 |
+
// If the block is unique, store it
|
| 105 |
+
if _, exists := uniqueBlocks[hash]; !exists {
|
| 106 |
+
uniqueBlocks[hash] = block
|
| 107 |
+
blockIds[hash] = id
|
| 108 |
+
tiles = append( tiles, block )
|
| 109 |
+
id++
|
| 110 |
+
}
|
| 111 |
+
tilemap=append(tilemap,blockIds[hash])
|
| 112 |
+
w++
|
| 113 |
+
// round up the map width to the nearest power of 2
|
| 114 |
+
if w==map_width && tilemap_args.wround {
|
| 115 |
+
for w < (1<<map_wround) {
|
| 116 |
+
tilemap=append(tilemap,0)
|
| 117 |
+
w++
|
| 118 |
+
}
|
| 119 |
+
w=0
|
| 120 |
+
}
|
| 121 |
+
}
|
| 122 |
+
}
|
| 123 |
+
|
| 124 |
+
pal := makePal(uniqueBlocks)
|
| 125 |
+
bpp := int(math.Ceil(math.Log2(float64(len(pal)))))
|
| 126 |
+
tileData := packTiles( dumpTiles( tiles, pal ), bpp )
|
| 127 |
+
if tilemap_args.array {
|
| 128 |
+
arraydump( ofname+"map.sv", tilemap, 1 )
|
| 129 |
+
arraydump( ofname+"data.sv", tileData, bpp )
|
| 130 |
+
} else {
|
| 131 |
+
hexdump( ofname+"map.hex", tilemap, 1)
|
| 132 |
+
hexdump( ofname+"data.hex", tileData, bpp )
|
| 133 |
+
}
|
| 134 |
+
if verbose {
|
| 135 |
+
fmt.Printf("Total unique 8x8 tiles: %d\n", len(uniqueBlocks))
|
| 136 |
+
fmt.Println("Total",len(pal),"colors")
|
| 137 |
+
}
|
| 138 |
+
}
|
| 139 |
+
|
| 140 |
+
func packTiles( tiles []int, bpp int ) []byte {
|
| 141 |
+
if bpp==0 || bpp!=2 || 8%bpp!=0 {
|
| 142 |
+
fmt.Println("Unsupported bpp encoding")
|
| 143 |
+
os.Exit(1)
|
| 144 |
+
}
|
| 145 |
+
|
| 146 |
+
pack := 8/bpp
|
| 147 |
+
data := make([]byte,len(tiles)/pack)
|
| 148 |
+
for k, _ := range data {
|
| 149 |
+
data[k]=0
|
| 150 |
+
}
|
| 151 |
+
sh := bpp-1
|
| 152 |
+
for i,each := range tiles {
|
| 153 |
+
ish := (i>>3) << sh
|
| 154 |
+
imod := (^i)&7
|
| 155 |
+
for j:=0; j<bpp; j++ {
|
| 156 |
+
data[ ish+j ] |= byte(((each>>j)&1) << imod)
|
| 157 |
+
}
|
| 158 |
+
}
|
| 159 |
+
return data
|
| 160 |
+
}
|
| 161 |
+
|
| 162 |
+
func dumpTiles( tiles []image.Image, pal map[int]int ) []int {
|
| 163 |
+
intdump := make([]int,len(tiles)<<6)
|
| 164 |
+
k:=0
|
| 165 |
+
for _,each := range tiles {
|
| 166 |
+
r := each.Bounds()
|
| 167 |
+
for y := r.Min.Y; y < r.Max.Y; y ++ {
|
| 168 |
+
for x := r.Min.X; x < r.Max.X; x ++ {
|
| 169 |
+
rgb := rgbPack(each.At(x,y))
|
| 170 |
+
intdump[k] = pal[rgb]
|
| 171 |
+
k++
|
| 172 |
+
}
|
| 173 |
+
}
|
| 174 |
+
}
|
| 175 |
+
return intdump
|
| 176 |
+
}
|
| 177 |
+
|
| 178 |
+
func rgbPack( c color.Color ) int {
|
| 179 |
+
r,g,b,_ := c.RGBA()
|
| 180 |
+
return ((int(r)&0xff)<<16) | ((int(g)&0xff)<<8) | (int(b)&0xff)
|
| 181 |
+
}
|
| 182 |
+
|
| 183 |
+
func makePal( tiles map[string]image.Image ) map[int]int {
|
| 184 |
+
pal := make(map[int]int)
|
| 185 |
+
k := 0
|
| 186 |
+
for _, each := range tiles {
|
| 187 |
+
r := each.Bounds()
|
| 188 |
+
for y := r.Min.Y; y < r.Max.Y; y ++ {
|
| 189 |
+
for x := r.Min.X; x < r.Max.X; x ++ {
|
| 190 |
+
rgb := rgbPack(each.At(x,y))
|
| 191 |
+
if _, found := pal[rgb]; !found {
|
| 192 |
+
pal[rgb] = k
|
| 193 |
+
k++
|
| 194 |
+
}
|
| 195 |
+
}
|
| 196 |
+
}
|
| 197 |
+
}
|
| 198 |
+
return pal
|
| 199 |
+
}
|
| 200 |
+
|
| 201 |
+
// input data is truncated to 8 bits
|
| 202 |
+
func hexdump[E int|byte]( fname string, data []E, bpp int ) {
|
| 203 |
+
f, e := os.Create(fname)
|
| 204 |
+
if e!=nil {
|
| 205 |
+
fmt.Println(e)
|
| 206 |
+
os.Exit(1)
|
| 207 |
+
}
|
| 208 |
+
defer f.Close()
|
| 209 |
+
format := fmt.Sprintf("%%0%dX\n",bpp<<1)
|
| 210 |
+
for k:=0; k<len(data); k+=bpp {
|
| 211 |
+
var v8 int
|
| 212 |
+
for j:=0; j<bpp; j++ {
|
| 213 |
+
v:=int(data[k+j])
|
| 214 |
+
if v>255 {
|
| 215 |
+
fmt.Println("Error: only 1-byte numbers allowed")
|
| 216 |
+
os.Exit(1)
|
| 217 |
+
}
|
| 218 |
+
v8 |= v<<(j<<3)
|
| 219 |
+
}
|
| 220 |
+
fmt.Fprintf(f,format,v8)
|
| 221 |
+
}
|
| 222 |
+
// the dump length is always extended to match a power of 2
|
| 223 |
+
// in order to prevent Quartus warnings when loading the data into a BRAM
|
| 224 |
+
rounded := 1<<int(math.Ceil(math.Log2(float64(len(data)))))
|
| 225 |
+
for k:=len(data); k <rounded; k+=bpp {
|
| 226 |
+
fmt.Fprintf(f,format,0)
|
| 227 |
+
}
|
| 228 |
+
}
|
| 229 |
+
|
| 230 |
+
func arraydump[E int|byte]( fname string, data []E, bpp int ) {
|
| 231 |
+
f, e := os.Create(fname)
|
| 232 |
+
if e!=nil {
|
| 233 |
+
fmt.Println(e)
|
| 234 |
+
os.Exit(1)
|
| 235 |
+
}
|
| 236 |
+
defer f.Close()
|
| 237 |
+
fmt.Fprintf(f,"'{\n")
|
| 238 |
+
dw := bpp<<3
|
| 239 |
+
format := fmt.Sprintf("%%d'h%%0%dX",bpp<<1)
|
| 240 |
+
for k:=0; k<len(data); k+=bpp {
|
| 241 |
+
if k!=0 {
|
| 242 |
+
fmt.Fprintf(f,", ")
|
| 243 |
+
if (k&0xf) == 0 { fmt.Fprintln(f)}
|
| 244 |
+
}
|
| 245 |
+
var v8 int
|
| 246 |
+
for j:=0; j<bpp; j++ {
|
| 247 |
+
v:=int(data[k+j])
|
| 248 |
+
if v>255 {
|
| 249 |
+
fmt.Println("Error: only 1-byte numbers allowed")
|
| 250 |
+
os.Exit(1)
|
| 251 |
+
}
|
| 252 |
+
v8 |= v<<(j<<3)
|
| 253 |
+
}
|
| 254 |
+
fmt.Fprintf(f,format,dw,v8)
|
| 255 |
+
}
|
| 256 |
+
fmt.Fprintf(f," };\n")
|
| 257 |
+
}
|
| 258 |
+
|
| 259 |
+
|
| 260 |
+
func hashImage(img image.Image) string {
|
| 261 |
+
// Convert image to RGBA
|
| 262 |
+
bounds := img.Bounds()
|
| 263 |
+
rgba := image.NewRGBA(image.Rect(0, 0, bounds.Dx(), bounds.Dy()))
|
| 264 |
+
y0:=0
|
| 265 |
+
for y := bounds.Min.Y; y < bounds.Max.Y; y++ {
|
| 266 |
+
x0:=0
|
| 267 |
+
for x := bounds.Min.X; x < bounds.Max.X; x++ {
|
| 268 |
+
rgba.Set(x0, y0, img.At(x, y))
|
| 269 |
+
x0++
|
| 270 |
+
}
|
| 271 |
+
y0++
|
| 272 |
+
}
|
| 273 |
+
|
| 274 |
+
// Hash the RGBA values
|
| 275 |
+
hash := sha1.New()
|
| 276 |
+
hash.Write(rgba.Pix)
|
| 277 |
+
return hex.EncodeToString(hash.Sum(nil))
|
| 278 |
+
}
|
snapshots/jotego_jtcores_pr1270/modules/jtframe/src/jtutil/cmd/trace.go
ADDED
|
@@ -0,0 +1,145 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/* This file is part of JTCORES.
|
| 2 |
+
JTFRAME program is free software: you can redistribute it and/or modify
|
| 3 |
+
it under the terms of the GNU General Public License as published by
|
| 4 |
+
the Free Software Foundation, either version 3 of the License, or
|
| 5 |
+
(at your option) any later version.
|
| 6 |
+
|
| 7 |
+
JTFRAME program is distributed in the hope that it will be useful,
|
| 8 |
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
| 9 |
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
| 10 |
+
GNU General Public License for more details.
|
| 11 |
+
|
| 12 |
+
You should have received a copy of the GNU General Public License
|
| 13 |
+
along with JTFRAME. If not, see <http://www.gnu.org/licenses/>.
|
| 14 |
+
|
| 15 |
+
Author: Jose Tejada Gomez. Twitter: @topapate
|
| 16 |
+
Date: 4-1-2025 */
|
| 17 |
+
|
| 18 |
+
package cmd
|
| 19 |
+
|
| 20 |
+
import (
|
| 21 |
+
"jtutil/vcd"
|
| 22 |
+
"fmt"
|
| 23 |
+
"os"
|
| 24 |
+
"strings"
|
| 25 |
+
"github.com/spf13/cobra"
|
| 26 |
+
)
|
| 27 |
+
|
| 28 |
+
func init() {
|
| 29 |
+
const help=
|
| 30 |
+
`Use to debug a simulation against MAME.
|
| 31 |
+
Prepare a MAME trace file with register dumps, and a VCD file with the registers
|
| 32 |
+
you want to compare.
|
| 33 |
+
|
| 34 |
+
debug.trace text file generated with MAME
|
| 35 |
+
debug.vcd VCD file for comparison
|
| 36 |
+
|
| 37 |
+
File names can be overriden with --base-name
|
| 38 |
+
|
| 39 |
+
An automatic matching between the MAME variables and the VCD signal names will
|
| 40 |
+
be attempted. If a signal is not matched to MAME, manually add it with the alias
|
| 41 |
+
command.
|
| 42 |
+
|
| 43 |
+
The comparison is interactive, although a script can also be run to help in
|
| 44 |
+
debugging sessions. Type help to obtain the list of commands. The session
|
| 45 |
+
commands are stored in the file trace.ses (and overwritten each time).
|
| 46 |
+
|
| 47 |
+
The VCD comparison will not be done while these signals are high:
|
| 48 |
+
|
| 49 |
+
- alu_busy the ALU is busy solving a long operation
|
| 50 |
+
- str_busy a long string operation is in progress
|
| 51 |
+
- stack_busy processing long stack related operations
|
| 52 |
+
`
|
| 53 |
+
traceCmd := &cobra.Command{
|
| 54 |
+
Use: "trace",
|
| 55 |
+
Short: "Compare VCD file with MAME trace output",
|
| 56 |
+
Long: help,
|
| 57 |
+
Run: run_trace_cmd,
|
| 58 |
+
}
|
| 59 |
+
rootCmd.AddCommand(traceCmd)
|
| 60 |
+
flg := traceCmd.Flags()
|
| 61 |
+
|
| 62 |
+
flg.StringP("make", "m", "", "Create MAME trace file for the given CPU")
|
| 63 |
+
flg.StringP("base-name","b", "debug", ".trace and .vcd files with this name will be used")
|
| 64 |
+
}
|
| 65 |
+
|
| 66 |
+
func run_trace_cmd(cmd *cobra.Command, args []string) {
|
| 67 |
+
if make_sample_file,_ := cmd.Flags().GetString("make"); make_sample_file!="" {
|
| 68 |
+
makeMAME(make_sample_file)
|
| 69 |
+
return
|
| 70 |
+
}
|
| 71 |
+
basename,_ := cmd.Flags().GetString("base-name")
|
| 72 |
+
run_trace_comparison(basename)
|
| 73 |
+
}
|
| 74 |
+
|
| 75 |
+
func run_trace_comparison(basename string) {
|
| 76 |
+
trace := &vcd.LnFile{}
|
| 77 |
+
vcdf := &vcd.LnFile{}
|
| 78 |
+
vcdf.Open(basename+".vcd")
|
| 79 |
+
defer vcdf.Close()
|
| 80 |
+
signals := vcd.GetSignals(vcdf)
|
| 81 |
+
vcd.RenameRegs( signals )
|
| 82 |
+
|
| 83 |
+
trace.Open(basename+".trace")
|
| 84 |
+
defer trace.Close()
|
| 85 |
+
|
| 86 |
+
trace.Scan()
|
| 87 |
+
mame_alias := vcd.MakeAlias(trace.Text(), signals)
|
| 88 |
+
vcd.Prompt( vcdf, trace, signals, mame_alias )
|
| 89 |
+
}
|
| 90 |
+
|
| 91 |
+
func makeMAME( cpu string ) {
|
| 92 |
+
var s string
|
| 93 |
+
switch strings.ToLower(cpu) {
|
| 94 |
+
case "z80": s=`trace off
|
| 95 |
+
trace debug.trace,maincpu,noloop,{tracelog "PC=%4X,AF=%4X,BC=%4X,DE=%4X,HL=%4X,AF2=%4X,BC2=%4X,DE2=%4X,HL2=%4X,IX=%4X,IY=%4X,SP=%4X,* ",pc,af,bc,de,hl,af2,bc2,de2,hl2,ix,iy,sp}
|
| 96 |
+
`
|
| 97 |
+
case "t900h": s=`trace debug.trace,maincpu,noloop,{tracelog "PC=%X,XWA0=%X,XBC0=%X,XDE0=%X,XHL0=%X,XWA1=%X,XBC1=%X,XDE1=%X,XHL1=%X,XWA2=%X,XBC2=%X,XDE2=%X,XHL2=%X,XWA3=%X,XBC3=%X,XDE3=%X,XHL3=%X,XIX=%X,XIY=%X,XIZ=%X,XSP=%X,* ",pc,xwa0,xbc0,xde0,xhl0,xwa1,xbc1,xde1,xhl1,xwa2,xbc2,xde2,xhl2,xwa3,xbc3,xde3,xhl3,xix,xiy,xiz,xssp}
|
| 98 |
+
`
|
| 99 |
+
case "6301","6800","6801":
|
| 100 |
+
s=`focus 1
|
| 101 |
+
trace off
|
| 102 |
+
trace debug.trace,sub,noloop,{tracelog "PC=%X,S=%X,X=%X,CC=%X,A=%X,B=%X,frame_cnt=%x* ",pc,s,x,cc|c0,a,b,frame}
|
| 103 |
+
`
|
| 104 |
+
case "6805":
|
| 105 |
+
s=`focus 1
|
| 106 |
+
trace off
|
| 107 |
+
trace debug.trace,mcu,noloop,{tracelog "PC=%X,S=%X,X=%X,CC=%X,A=%X,PA_OUT=%X,PB_OUT=%X,PC_OUT=%X,PA_DDR=%X,PB_DDR=%X,PC_DDR=%X,frame_cnt=%x* ",pc,s,x,cc|c0,a,latcha,latchb,latchc,ddra,ddrb,ddrc,frame}
|
| 108 |
+
`
|
| 109 |
+
case "m68000","m68k","68k","68000":
|
| 110 |
+
s=`focus 0
|
| 111 |
+
trace off
|
| 112 |
+
trace debug.trace,maincpu,noloop,{tracelog "PC=%X,SSP=%X,D0=%X,D1=%X,D2=%X,D3=%X,D4=%X,D5=%X,D6=%X,D7=%X,A0=%X,A1=%X,A2=%X,A3=%X,A4=%X,A5=%X,A6=%X,A7=%X,IR=%X,frame_cnt=%x* ",rPC,SSP,d0,d1,d2,d3,d4,d5,d6,d7,a0,a1,a2,a3,a4,a5,a6,USP,ir,frame}
|
| 113 |
+
`
|
| 114 |
+
case "konami","kcpu","6809": s=`focus 0
|
| 115 |
+
trace off
|
| 116 |
+
trace debug.trace,maincpu,noloop,{tracelog "PC=%X,cc=%X,dp=%x,a=%x,b=%x,x=%x,y=%x,u=%x,s=%x,ticks=%x,frame_cnt=%x* ",pc,cc,dp,a,b,x,y,u,s,totalcycles,frame}
|
| 117 |
+
`
|
| 118 |
+
case "qsnd","qsound": s=`trace debug.trace,2,,{tracelog "! pc=%X pt=%X pr=%X pi=%X i=%X r0=%X r1=%X r2=%X r3=%X rb=%X re=%X j=%X k=%X x=%X y=%X p=%X a0=%X a1=%X c0=%X c1=%X c2=%X auc=%X psw=%X\n",pc,pt,pr,pi,i,r0,r1,r2,r3,rb,re,j,k,x,y,p,a0,a1,c0,c1,c2,auc,psw}
|
| 119 |
+
`
|
| 120 |
+
}
|
| 121 |
+
if s=="" {
|
| 122 |
+
fmt.Printf("No default trace.mame file for %s CPU. Add it to trace.go\n", cpu)
|
| 123 |
+
fmt.Printf(`Supported CPUs names and aliases:
|
| 124 |
+
z80
|
| 125 |
+
t900h
|
| 126 |
+
6800, 6301, 6801,
|
| 127 |
+
m68000, m68k, 68k, 68000
|
| 128 |
+
konami, kcpu, 6809
|
| 129 |
+
qsnd, qsound
|
| 130 |
+
`)
|
| 131 |
+
return
|
| 132 |
+
}
|
| 133 |
+
s += `
|
| 134 |
+
gtime 100
|
| 135 |
+
traceflush
|
| 136 |
+
`
|
| 137 |
+
f, e := os.Create("trace.mame")
|
| 138 |
+
defer f.Close()
|
| 139 |
+
if e!=nil {
|
| 140 |
+
fmt.Println(e)
|
| 141 |
+
return
|
| 142 |
+
}
|
| 143 |
+
f.WriteString(s)
|
| 144 |
+
fmt.Println("trace.mame created")
|
| 145 |
+
}
|
snapshots/jotego_jtcores_pr1270/modules/jtframe/src/jtutil/cmd/vcd.go
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/* This file is part of JTCORES.
|
| 2 |
+
JTFRAME program is free software: you can redistribute it and/or modify
|
| 3 |
+
it under the terms of the GNU General Public License as published by
|
| 4 |
+
the Free Software Foundation, either version 3 of the License, or
|
| 5 |
+
(at your option) any later version.
|
| 6 |
+
|
| 7 |
+
JTFRAME program is distributed in the hope that it will be useful,
|
| 8 |
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
| 9 |
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
| 10 |
+
GNU General Public License for more details.
|
| 11 |
+
|
| 12 |
+
You should have received a copy of the GNU General Public License
|
| 13 |
+
along with JTFRAME. If not, see <http://www.gnu.org/licenses/>.
|
| 14 |
+
|
| 15 |
+
Author: Jose Tejada Gomez. Twitter: @topapate
|
| 16 |
+
Date: 4-1-2025 */
|
| 17 |
+
|
| 18 |
+
package cmd
|
| 19 |
+
|
| 20 |
+
import (
|
| 21 |
+
"fmt"
|
| 22 |
+
|
| 23 |
+
"github.com/spf13/cobra"
|
| 24 |
+
)
|
| 25 |
+
|
| 26 |
+
// vcdCmd represents the vcd command
|
| 27 |
+
var vcdCmd = &cobra.Command{
|
| 28 |
+
Use: "vcd",
|
| 29 |
+
Short: "VCD file manipulation",
|
| 30 |
+
Long: `Several tools to manipulate VCD files`,
|
| 31 |
+
Run: func(cmd *cobra.Command, args []string) {
|
| 32 |
+
fmt.Println("Call vcd with one of the available subcommands")
|
| 33 |
+
},
|
| 34 |
+
Args: cobra.NoArgs,
|
| 35 |
+
}
|
| 36 |
+
|
| 37 |
+
func init() {
|
| 38 |
+
rootCmd.AddCommand(vcdCmd)
|
| 39 |
+
|
| 40 |
+
// Here you will define your flags and configuration settings.
|
| 41 |
+
|
| 42 |
+
// Cobra supports Persistent Flags which will work for this command
|
| 43 |
+
// and all subcommands, e.g.:
|
| 44 |
+
// vcdCmd.PersistentFlags().String("foo", "", "A help for foo")
|
| 45 |
+
|
| 46 |
+
// Cobra supports local flags which will only run when this command
|
| 47 |
+
// is called directly, e.g.:
|
| 48 |
+
// vcdCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle")
|
| 49 |
+
}
|
| 50 |
+
|
snapshots/jotego_jtcores_pr1270/modules/jtframe/src/jtutil/cmd/verilog.go
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/* This file is part of JTCORES.
|
| 2 |
+
JTFRAME program is free software: you can redistribute it and/or modify
|
| 3 |
+
it under the terms of the GNU General Public License as published by
|
| 4 |
+
the Free Software Foundation, either version 3 of the License, or
|
| 5 |
+
(at your option) any later version.
|
| 6 |
+
|
| 7 |
+
JTFRAME program is distributed in the hope that it will be useful,
|
| 8 |
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
| 9 |
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
| 10 |
+
GNU General Public License for more details.
|
| 11 |
+
|
| 12 |
+
You should have received a copy of the GNU General Public License
|
| 13 |
+
along with JTFRAME. If not, see <http://www.gnu.org/licenses/>.
|
| 14 |
+
|
| 15 |
+
Author: Jose Tejada Gomez. Twitter: @topapate
|
| 16 |
+
Date: 4-1-2025 */
|
| 17 |
+
|
| 18 |
+
package cmd
|
| 19 |
+
|
| 20 |
+
import (
|
| 21 |
+
"strings"
|
| 22 |
+
|
| 23 |
+
"jtutil/vcd"
|
| 24 |
+
"github.com/spf13/cobra"
|
| 25 |
+
)
|
| 26 |
+
|
| 27 |
+
// verilogCmd represents the verilog command
|
| 28 |
+
var verilogCmd = &cobra.Command{
|
| 29 |
+
Use: "verilog file[.vcd]",
|
| 30 |
+
Short: "Converts a VCD to a verilog .bin and .v files for simulation use",
|
| 31 |
+
//Long:
|
| 32 |
+
Run: verilogCmdRun,
|
| 33 |
+
Args: cobra.ExactArgs(1),
|
| 34 |
+
}
|
| 35 |
+
|
| 36 |
+
func verilogCmdRun(cmd *cobra.Command, args []string) {
|
| 37 |
+
fname := args[0]
|
| 38 |
+
if strings.HasSuffix(args[0],".vcd") {
|
| 39 |
+
fname = args[0][0:len(args[0])-4]
|
| 40 |
+
}
|
| 41 |
+
var d vcd.LnFile
|
| 42 |
+
d.Open(fname+".vcd")
|
| 43 |
+
ss := vcd.GetSignals(&d)
|
| 44 |
+
must(d.DumpHex(ss,fname))
|
| 45 |
+
}
|
| 46 |
+
|
| 47 |
+
func init() {
|
| 48 |
+
vcdCmd.AddCommand(verilogCmd)
|
| 49 |
+
}
|
| 50 |
+
|
snapshots/jotego_jtcores_pr1270/modules/jtframe/src/jtutil/cmd/wav/parser.go
ADDED
|
@@ -0,0 +1,135 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
package wav
|
| 2 |
+
|
| 3 |
+
import(
|
| 4 |
+
"fmt"
|
| 5 |
+
"os"
|
| 6 |
+
"slices"
|
| 7 |
+
"strings"
|
| 8 |
+
|
| 9 |
+
"jtutil/vcd"
|
| 10 |
+
"github.com/spf13/cobra"
|
| 11 |
+
)
|
| 12 |
+
|
| 13 |
+
type wav_parser_t struct{
|
| 14 |
+
input_fname, signal_name, output_fname string
|
| 15 |
+
lnfile *vcd.LnFile
|
| 16 |
+
signal *vcd.VCDSignal
|
| 17 |
+
ss vcd.VCDData
|
| 18 |
+
wav_file *WavFile
|
| 19 |
+
repeat float64
|
| 20 |
+
skip_silence bool
|
| 21 |
+
}
|
| 22 |
+
|
| 23 |
+
func RunWavCmd(cmd *cobra.Command, args []string) {
|
| 24 |
+
parser := wav_parser_t{
|
| 25 |
+
lnfile: &vcd.LnFile{},
|
| 26 |
+
input_fname: "test.vcd",
|
| 27 |
+
}
|
| 28 |
+
|
| 29 |
+
if len(args)>0 { parser.input_fname = args[0] }
|
| 30 |
+
|
| 31 |
+
parser.signal_name,_ = cmd.Flags().GetString("signal")
|
| 32 |
+
parser.output_fname,_ = cmd.Flags().GetString("output")
|
| 33 |
+
parser.skip_silence,_ = cmd.Flags().GetBool("skip")
|
| 34 |
+
e := parser.Parse()
|
| 35 |
+
if e!=nil {
|
| 36 |
+
fmt.Println(e)
|
| 37 |
+
os.Exit(1)
|
| 38 |
+
}
|
| 39 |
+
}
|
| 40 |
+
|
| 41 |
+
func (w *wav_parser_t)Parse() error {
|
| 42 |
+
w.lnfile.Open(w.input_fname)
|
| 43 |
+
defer w.lnfile.Close()
|
| 44 |
+
w.ss = vcd.GetSignals(w.lnfile)
|
| 45 |
+
e := w.validate_signals(); if e!=nil { return e }
|
| 46 |
+
w.wav_file = MakeWav()
|
| 47 |
+
w.move_vcd_data_to_wav()
|
| 48 |
+
return w.wav_file.Dump(w.output_fname)
|
| 49 |
+
}
|
| 50 |
+
|
| 51 |
+
func (w *wav_parser_t)validate_signals() error {
|
| 52 |
+
if len(w.ss)==0 {
|
| 53 |
+
return fmt.Errorf("Empty VCD file")
|
| 54 |
+
}
|
| 55 |
+
if w.signal_name=="" {
|
| 56 |
+
if len(w.ss)==1 {
|
| 57 |
+
for name,sgn := range w.ss {
|
| 58 |
+
w.signal_name = name
|
| 59 |
+
w.signal = sgn
|
| 60 |
+
return nil
|
| 61 |
+
}
|
| 62 |
+
} else {
|
| 63 |
+
all_names := w.collect_signal_names()
|
| 64 |
+
return fmt.Errorf("No signal name provided but VCD has multiple options:\n%s", all_names)
|
| 65 |
+
}
|
| 66 |
+
}
|
| 67 |
+
e := w.find_signal()
|
| 68 |
+
if e!=nil {
|
| 69 |
+
all_names := w.collect_signal_names()
|
| 70 |
+
return fmt.Errorf("%w.\nValid names:\n %s", e, all_names)
|
| 71 |
+
}
|
| 72 |
+
return nil
|
| 73 |
+
}
|
| 74 |
+
|
| 75 |
+
func (w *wav_parser_t)collect_signal_names() string {
|
| 76 |
+
names := make([]string,len(w.ss))
|
| 77 |
+
k:=0
|
| 78 |
+
for _, sgn := range w.ss {
|
| 79 |
+
names[k] = sgn.FullName()
|
| 80 |
+
k++
|
| 81 |
+
}
|
| 82 |
+
slices.Sort(names)
|
| 83 |
+
return strings.Join(names,"\n")
|
| 84 |
+
}
|
| 85 |
+
|
| 86 |
+
func (w *wav_parser_t)find_signal() error {
|
| 87 |
+
matches := make([]*vcd.VCDSignal,0,len(w.ss))
|
| 88 |
+
for _,sgn := range w.ss {
|
| 89 |
+
if strings.HasSuffix( sgn.FullName(), w.signal_name ) {
|
| 90 |
+
matches=append(matches,sgn)
|
| 91 |
+
}
|
| 92 |
+
}
|
| 93 |
+
switch len(matches) {
|
| 94 |
+
case 0: return fmt.Errorf("Signal %s not found", w.signal_name)
|
| 95 |
+
case 1: w.signal = matches[0]
|
| 96 |
+
default: return fmt.Errorf("Too many matches for name %s", w.signal_name)
|
| 97 |
+
}
|
| 98 |
+
return nil
|
| 99 |
+
}
|
| 100 |
+
|
| 101 |
+
func (w *wav_parser_t)move_vcd_data_to_wav() {
|
| 102 |
+
for {
|
| 103 |
+
w.write_value_to_wav()
|
| 104 |
+
if !w.next() { break }
|
| 105 |
+
}
|
| 106 |
+
}
|
| 107 |
+
|
| 108 |
+
func (w *wav_parser_t)write_value_to_wav() {
|
| 109 |
+
snd := w.get_16bit_value()
|
| 110 |
+
if w.skip_silence==true && snd==0 { return }
|
| 111 |
+
w.skip_silence = false
|
| 112 |
+
for w.repeat>=1.0 {
|
| 113 |
+
w.wav_file.append(snd)
|
| 114 |
+
w.repeat -= 1.0
|
| 115 |
+
}
|
| 116 |
+
}
|
| 117 |
+
|
| 118 |
+
func (w *wav_parser_t)get_16bit_value() int16 {
|
| 119 |
+
if w.signal.MSB==15 { return int16(w.signal.Value) }
|
| 120 |
+
if w.signal.MSB <15 { return int16(w.signal.Value<<(15-w.signal.MSB)) }
|
| 121 |
+
// > 15
|
| 122 |
+
return int16(w.signal.Value>>(w.signal.MSB-15))
|
| 123 |
+
|
| 124 |
+
}
|
| 125 |
+
|
| 126 |
+
func (w *wav_parser_t)next() bool {
|
| 127 |
+
const period_48k_in_ps = 20833333
|
| 128 |
+
tnow := w.lnfile.Time()
|
| 129 |
+
tnext := tnow + period_48k_in_ps
|
| 130 |
+
is_new_data := w.lnfile.MoveTo(w.ss,tnext)
|
| 131 |
+
if !is_new_data { return false }
|
| 132 |
+
tnext = w.lnfile.Time()
|
| 133 |
+
w.repeat += (float64(tnext)-float64(tnow))/float64(period_48k_in_ps)
|
| 134 |
+
return true
|
| 135 |
+
}
|
snapshots/jotego_jtcores_pr1270/modules/jtframe/src/jtutil/cmd/wav/wav.go
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
package wav
|
| 2 |
+
|
| 3 |
+
import(
|
| 4 |
+
"os"
|
| 5 |
+
)
|
| 6 |
+
|
| 7 |
+
type WavFile struct{
|
| 8 |
+
buf []byte
|
| 9 |
+
}
|
| 10 |
+
|
| 11 |
+
func MakeWav() *WavFile {
|
| 12 |
+
wav := WavFile{
|
| 13 |
+
buf: make([]byte,44,2*1024*1024),
|
| 14 |
+
}
|
| 15 |
+
wav.make_header()
|
| 16 |
+
return &wav
|
| 17 |
+
}
|
| 18 |
+
|
| 19 |
+
func (w *WavFile)make_header() {
|
| 20 |
+
copy(w.buf,[]byte("RIFF"))
|
| 21 |
+
copy(w.buf[8:],[]byte("WAVEfmt "))
|
| 22 |
+
copy(w.buf[36:],[]byte("data"))
|
| 23 |
+
w.buf[16]=16 // 16-bit sound
|
| 24 |
+
w.buf[20]=1
|
| 25 |
+
w.buf[22]=2
|
| 26 |
+
sample_rate := uint32(48000)
|
| 27 |
+
w.write32(24,sample_rate)
|
| 28 |
+
w.write32(28,sample_rate*4)
|
| 29 |
+
w.buf[32]=4
|
| 30 |
+
w.buf[34] = 16
|
| 31 |
+
}
|
| 32 |
+
|
| 33 |
+
func (w *WavFile)write32(offset int, value uint32) {
|
| 34 |
+
w.buf[offset+0] = byte((value>> 0)&0xff)
|
| 35 |
+
w.buf[offset+1] = byte((value>> 8)&0xff)
|
| 36 |
+
w.buf[offset+2] = byte((value>>16)&0xff)
|
| 37 |
+
w.buf[offset+3] = byte((value>>24)&0xff)
|
| 38 |
+
}
|
| 39 |
+
|
| 40 |
+
func (w *WavFile)append( value int16 ) {
|
| 41 |
+
asbytes := []byte{byte(value),byte(value>>8)}
|
| 42 |
+
w.buf=append(w.buf,asbytes...) // left
|
| 43 |
+
w.buf=append(w.buf,asbytes...) // right
|
| 44 |
+
}
|
| 45 |
+
|
| 46 |
+
func (w *WavFile)Dump(fname string) error {
|
| 47 |
+
w.write32(4, uint32(len(w.buf)))
|
| 48 |
+
w.write32(40, uint32(len(w.buf)-44))
|
| 49 |
+
return os.WriteFile(fname,w.buf,0664)
|
| 50 |
+
}
|
snapshots/jotego_jtcores_pr1270/modules/jtframe/src/jtutil/go.mod
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
module jtutil
|
| 2 |
+
|
| 3 |
+
go 1.22.0
|
| 4 |
+
|
| 5 |
+
toolchain go1.23.4
|
| 6 |
+
|
| 7 |
+
require (
|
| 8 |
+
github.com/PaesslerAG/gval v1.2.2
|
| 9 |
+
jotego/jtframe v0.0.0-00010101000000-000000000000
|
| 10 |
+
github.com/spf13/cobra v1.7.0
|
| 11 |
+
)
|
| 12 |
+
|
| 13 |
+
require (
|
| 14 |
+
github.com/Masterminds/goutils v1.1.1 // indirect
|
| 15 |
+
github.com/Masterminds/semver/v3 v3.2.0 // indirect
|
| 16 |
+
github.com/Masterminds/sprig/v3 v3.2.3 // indirect
|
| 17 |
+
github.com/google/uuid v1.1.1 // indirect
|
| 18 |
+
github.com/huandu/xstrings v1.3.3 // indirect
|
| 19 |
+
github.com/imdario/mergo v0.3.11 // indirect
|
| 20 |
+
github.com/inconshreveable/mousetrap v1.1.0 // indirect
|
| 21 |
+
github.com/komkom/toml v0.1.2 // indirect
|
| 22 |
+
github.com/mitchellh/copystructure v1.0.0 // indirect
|
| 23 |
+
github.com/mitchellh/reflectwalk v1.0.0 // indirect
|
| 24 |
+
github.com/pkg/errors v0.9.1 // indirect
|
| 25 |
+
github.com/shopspring/decimal v1.3.1 // indirect
|
| 26 |
+
github.com/spf13/cast v1.3.1 // indirect
|
| 27 |
+
github.com/spf13/pflag v1.0.5 // indirect
|
| 28 |
+
golang.org/x/crypto v0.3.0 // indirect
|
| 29 |
+
golang.org/x/exp v0.0.0-20250106191152-7588d65b2ba8 // indirect
|
| 30 |
+
gopkg.in/yaml.v2 v2.4.0 // indirect
|
| 31 |
+
)
|
| 32 |
+
|
| 33 |
+
replace jotego/jtframe => ../jtframe
|
snapshots/jotego_jtcores_pr1270/modules/jtframe/src/jtutil/go.sum
ADDED
|
@@ -0,0 +1,87 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
github.com/Masterminds/goutils v1.1.1 h1:5nUrii3FMTL5diU80unEVvNevw1nH4+ZV4DSLVJLSYI=
|
| 2 |
+
github.com/Masterminds/goutils v1.1.1/go.mod h1:8cTjp+g8YejhMuvIA5y2vz3BpJxksy863GQaJW2MFNU=
|
| 3 |
+
github.com/Masterminds/semver/v3 v3.2.0 h1:3MEsd0SM6jqZojhjLWWeBY+Kcjy9i6MQAeY7YgDP83g=
|
| 4 |
+
github.com/Masterminds/semver/v3 v3.2.0/go.mod h1:qvl/7zhW3nngYb5+80sSMF+FG2BjYrf8m9wsX0PNOMQ=
|
| 5 |
+
github.com/Masterminds/sprig/v3 v3.2.3 h1:eL2fZNezLomi0uOLqjQoN6BfsDD+fyLtgbJMAj9n6YA=
|
| 6 |
+
github.com/Masterminds/sprig/v3 v3.2.3/go.mod h1:rXcFaZ2zZbLRJv/xSysmlgIM1u11eBaRMhvYXJNkGuM=
|
| 7 |
+
github.com/PaesslerAG/gval v1.2.2 h1:Y7iBzhgE09IGTt5QgGQ2IdaYYYOU134YGHBThD+wm9E=
|
| 8 |
+
github.com/PaesslerAG/gval v1.2.2/go.mod h1:XRFLwvmkTEdYziLdaCeCa5ImcGVrfQbeNUbVR+C6xac=
|
| 9 |
+
github.com/PaesslerAG/jsonpath v0.1.0 h1:gADYeifvlqK3R3i2cR5B4DGgxLXIPb3TRTH1mGi0jPI=
|
| 10 |
+
github.com/PaesslerAG/jsonpath v0.1.0/go.mod h1:4BzmtoM/PI8fPO4aQGIusjGxGir2BzcV0grWtFzq1Y8=
|
| 11 |
+
github.com/cpuguy83/go-md2man/v2 v2.0.2/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
|
| 12 |
+
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
| 13 |
+
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
| 14 |
+
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
| 15 |
+
github.com/google/uuid v1.1.1 h1:Gkbcsh/GbpXz7lPftLA3P6TYMwjCLYm83jiFQZF/3gY=
|
| 16 |
+
github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
| 17 |
+
github.com/huandu/xstrings v1.3.3 h1:/Gcsuc1x8JVbJ9/rlye4xZnVAbEkGauT8lbebqcQws4=
|
| 18 |
+
github.com/huandu/xstrings v1.3.3/go.mod h1:y5/lhBue+AyNmUVz9RLU9xbLR0o4KIIExikq4ovT0aE=
|
| 19 |
+
github.com/imdario/mergo v0.3.11 h1:3tnifQM4i+fbajXKBHXWEH+KvNHqojZ778UH75j3bGA=
|
| 20 |
+
github.com/imdario/mergo v0.3.11/go.mod h1:jmQim1M+e3UYxmgPu/WyfjB3N3VflVyUjjjwH0dnCYA=
|
| 21 |
+
github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8=
|
| 22 |
+
github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw=
|
| 23 |
+
github.com/komkom/toml v0.1.2 h1:SexwnY3JOR0kU9F/xxw/129BPCvuKi6/E89PZ4kSSBo=
|
| 24 |
+
github.com/komkom/toml v0.1.2/go.mod h1:cgnL/ntRyMHaZuDy9wREJHWY1Cb2HEINK7U0YhpcTa8=
|
| 25 |
+
github.com/mitchellh/copystructure v1.0.0 h1:Laisrj+bAB6b/yJwB5Bt3ITZhGJdqmxquMKeZ+mmkFQ=
|
| 26 |
+
github.com/mitchellh/copystructure v1.0.0/go.mod h1:SNtv71yrdKgLRyLFxmLdkAbkKEFWgYaq1OVrnRcwhnw=
|
| 27 |
+
github.com/mitchellh/reflectwalk v1.0.0 h1:9D+8oIskB4VJBN5SFlmc27fSlIBZaov1Wpk/IfikLNY=
|
| 28 |
+
github.com/mitchellh/reflectwalk v1.0.0/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx0jmZXqmk4esnw=
|
| 29 |
+
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
|
| 30 |
+
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
| 31 |
+
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
| 32 |
+
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
| 33 |
+
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
|
| 34 |
+
github.com/shopspring/decimal v1.2.0/go.mod h1:DKyhrW/HYNuLGql+MJL6WCR6knT2jwCFRcu2hWCYk4o=
|
| 35 |
+
github.com/shopspring/decimal v1.3.1 h1:2Usl1nmF/WZucqkFZhnfFYxxxu8LG21F6nPQBE5gKV8=
|
| 36 |
+
github.com/shopspring/decimal v1.3.1/go.mod h1:DKyhrW/HYNuLGql+MJL6WCR6knT2jwCFRcu2hWCYk4o=
|
| 37 |
+
github.com/spf13/cast v1.3.1 h1:nFm6S0SMdyzrzcmThSipiEubIDy8WEXKNZ0UOgiRpng=
|
| 38 |
+
github.com/spf13/cast v1.3.1/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE=
|
| 39 |
+
github.com/spf13/cobra v1.7.0 h1:hyqWnYt1ZQShIddO5kBpj3vu05/++x6tJ6dg8EC572I=
|
| 40 |
+
github.com/spf13/cobra v1.7.0/go.mod h1:uLxZILRyS/50WlhOIKD7W6V5bgeIt+4sICxh6uRMrb0=
|
| 41 |
+
github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA=
|
| 42 |
+
github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
|
| 43 |
+
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
| 44 |
+
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
|
| 45 |
+
github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA=
|
| 46 |
+
github.com/stretchr/testify v1.6.1 h1:hDPOHmpOpP40lSULcqw7IrRb/u7w6RpDC9399XyoNd0=
|
| 47 |
+
github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
| 48 |
+
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
|
| 49 |
+
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
| 50 |
+
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
|
| 51 |
+
golang.org/x/crypto v0.3.0 h1:a06MkbcxBrEFc0w0QIZWXrH/9cCX6KJyWbBOIwAn+7A=
|
| 52 |
+
golang.org/x/crypto v0.3.0/go.mod h1:hebNnKkNXi2UzZN1eVRvBB7co0a+JxK6XbPiWVs/3J4=
|
| 53 |
+
golang.org/x/exp v0.0.0-20250106191152-7588d65b2ba8 h1:yqrTHse8TCMW1M1ZCP+VAR/l0kKxwaAIqN/il7x4voA=
|
| 54 |
+
golang.org/x/exp v0.0.0-20250106191152-7588d65b2ba8/go.mod h1:tujkw807nyEEAamNbDrEGzRav+ilXA7PCRAd6xsmwiU=
|
| 55 |
+
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
|
| 56 |
+
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
| 57 |
+
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
|
| 58 |
+
golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
|
| 59 |
+
golang.org/x/net v0.2.0/go.mod h1:KqCZLdyyvdV855qA2rE3GC2aiw5xGR5TEjj8smXukLY=
|
| 60 |
+
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
| 61 |
+
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
| 62 |
+
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
| 63 |
+
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
| 64 |
+
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
| 65 |
+
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
| 66 |
+
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
| 67 |
+
golang.org/x/sys v0.2.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
| 68 |
+
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
| 69 |
+
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
|
| 70 |
+
golang.org/x/term v0.2.0/go.mod h1:TVmDHMZPmdnySmBfhjOoOdhjzdE1h4u1VwSiw2l1Nuc=
|
| 71 |
+
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
| 72 |
+
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
| 73 |
+
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
|
| 74 |
+
golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
|
| 75 |
+
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
| 76 |
+
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
| 77 |
+
golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=
|
| 78 |
+
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
| 79 |
+
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
|
| 80 |
+
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
| 81 |
+
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
| 82 |
+
gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
| 83 |
+
gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
|
| 84 |
+
gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
|
| 85 |
+
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
| 86 |
+
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
| 87 |
+
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
snapshots/jotego_jtcores_pr1270/modules/jtframe/src/jtutil/main.go
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/* This file is part of JTCORES.
|
| 2 |
+
JTFRAME program is free software: you can redistribute it and/or modify
|
| 3 |
+
it under the terms of the GNU General Public License as published by
|
| 4 |
+
the Free Software Foundation, either version 3 of the License, or
|
| 5 |
+
(at your option) any later version.
|
| 6 |
+
|
| 7 |
+
JTFRAME program is distributed in the hope that it will be useful,
|
| 8 |
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
| 9 |
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
| 10 |
+
GNU General Public License for more details.
|
| 11 |
+
|
| 12 |
+
You should have received a copy of the GNU General Public License
|
| 13 |
+
along with JTFRAME. If not, see <http://www.gnu.org/licenses/>.
|
| 14 |
+
|
| 15 |
+
Author: Jose Tejada Gomez. Twitter: @topapate
|
| 16 |
+
Date: 4-1-2025 */
|
| 17 |
+
|
| 18 |
+
package main
|
| 19 |
+
|
| 20 |
+
import "jtutil/cmd"
|
| 21 |
+
|
| 22 |
+
func main() {
|
| 23 |
+
cmd.Execute()
|
| 24 |
+
}
|
snapshots/jotego_jtcores_pr1270/modules/jtframe/src/jtutil/vcd/compare.go
ADDED
|
@@ -0,0 +1,212 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/* This file is part of JTCORES.
|
| 2 |
+
JTFRAME program is free software: you can redistribute it and/or modify
|
| 3 |
+
it under the terms of the GNU General Public License as published by
|
| 4 |
+
the Free Software Foundation, either version 3 of the License, or
|
| 5 |
+
(at your option) any later version.
|
| 6 |
+
|
| 7 |
+
JTFRAME program is distributed in the hope that it will be useful,
|
| 8 |
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
| 9 |
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
| 10 |
+
GNU General Public License for more details.
|
| 11 |
+
|
| 12 |
+
You should have received a copy of the GNU General Public License
|
| 13 |
+
along with JTFRAME. If not, see <http://www.gnu.org/licenses/>.
|
| 14 |
+
|
| 15 |
+
Author: Jose Tejada Gomez. Twitter: @topapate
|
| 16 |
+
Date: 4-1-2025 */
|
| 17 |
+
|
| 18 |
+
package vcd
|
| 19 |
+
|
| 20 |
+
import (
|
| 21 |
+
"fmt"
|
| 22 |
+
"strings"
|
| 23 |
+
"os"
|
| 24 |
+
)
|
| 25 |
+
|
| 26 |
+
type CmpArgs struct {
|
| 27 |
+
Ignore_rst bool
|
| 28 |
+
Mismatch_n int
|
| 29 |
+
Time0a, Time0b uint64
|
| 30 |
+
}
|
| 31 |
+
|
| 32 |
+
type cmpData struct {
|
| 33 |
+
file *LnFile
|
| 34 |
+
data VCDData
|
| 35 |
+
signal *VCDSignal
|
| 36 |
+
resets []*VCDSignal
|
| 37 |
+
}
|
| 38 |
+
|
| 39 |
+
func (this cmpData) next() bool {
|
| 40 |
+
return this.file.NextVCD(this.data)
|
| 41 |
+
}
|
| 42 |
+
|
| 43 |
+
func in_reset(cmpd *cmpData) bool {
|
| 44 |
+
for _, rst := range cmpd.resets {
|
| 45 |
+
if rst.Value==1 { return true }
|
| 46 |
+
}
|
| 47 |
+
return false
|
| 48 |
+
}
|
| 49 |
+
|
| 50 |
+
func mv_reset( cmpd *cmpData ) {
|
| 51 |
+
// ensure that we are in reset state
|
| 52 |
+
for _, rst := range cmpd.resets {
|
| 53 |
+
for rst.Value!=1 && cmpd.file.NextVCD(cmpd.data) { }
|
| 54 |
+
}
|
| 55 |
+
// next, come out of it
|
| 56 |
+
for _, rst := range cmpd.resets {
|
| 57 |
+
for rst.Value!=0 && cmpd.file.NextVCD(cmpd.data) { }
|
| 58 |
+
}
|
| 59 |
+
}
|
| 60 |
+
|
| 61 |
+
func CompareAll( fnames []string, args CmpArgs ) {
|
| 62 |
+
var c [2]cmpData
|
| 63 |
+
for k,_ := range c{
|
| 64 |
+
c[k].file = &LnFile{}
|
| 65 |
+
if !strings.HasSuffix(fnames[k],".vcd") {
|
| 66 |
+
fnames[k] += ".vcd"
|
| 67 |
+
}
|
| 68 |
+
c[k].file.Open(fnames[k])
|
| 69 |
+
c[k].data = GetSignals(c[k].file)
|
| 70 |
+
c[k].resets=c[k].data.GetAll("rst",false)
|
| 71 |
+
}
|
| 72 |
+
if c[0].resets!=nil {
|
| 73 |
+
fmt.Println("rst signals found")
|
| 74 |
+
}
|
| 75 |
+
pairs := make(map[string]*VCDSignal)
|
| 76 |
+
k:=0
|
| 77 |
+
// find each signal pair in the other set
|
| 78 |
+
for _, signal := range c[0].data {
|
| 79 |
+
matched := c[1].data.Get( signal.FullName() )
|
| 80 |
+
if matched == nil {
|
| 81 |
+
for _, each := range c[1].data {
|
| 82 |
+
fmt.Println(each.FullName())
|
| 83 |
+
}
|
| 84 |
+
fmt.Println("Cannot find pair for signal ", signal.FullName())
|
| 85 |
+
return
|
| 86 |
+
}
|
| 87 |
+
pairs[signal.alias] = matched
|
| 88 |
+
k++
|
| 89 |
+
}
|
| 90 |
+
// function to compare the two sets
|
| 91 |
+
equal := func() (bool, string, uint64, uint64) {
|
| 92 |
+
for ref, cmp := range pairs {
|
| 93 |
+
if c[0].data[ref].Value != cmp.Value {
|
| 94 |
+
// fmt.Printf("%s <--> %s\n", c[0].data[ref].FullName(), cmp.FullName())
|
| 95 |
+
return false, cmp.FullName(), c[0].data[ref].Value, cmp.Value
|
| 96 |
+
}
|
| 97 |
+
}
|
| 98 |
+
return true,"",0,0
|
| 99 |
+
}
|
| 100 |
+
c[0].file.MoveTo(c[0].data,args.Time0a)
|
| 101 |
+
c[1].file.MoveTo(c[1].data,args.Time0b)
|
| 102 |
+
// run through the VCD
|
| 103 |
+
for c[0].file.NextVCD(c[0].data) {
|
| 104 |
+
matched := false
|
| 105 |
+
var offender string
|
| 106 |
+
var v0,v1 uint64
|
| 107 |
+
more := true
|
| 108 |
+
t1 := c[1].file.time
|
| 109 |
+
more = c[1].file.NextVCD(c[1].data)
|
| 110 |
+
if args.Ignore_rst {
|
| 111 |
+
if in_reset(&c[0]) || in_reset(&c[1]) {
|
| 112 |
+
mv_reset(&c[0])
|
| 113 |
+
mv_reset(&c[1])
|
| 114 |
+
}
|
| 115 |
+
}
|
| 116 |
+
matched, offender, v0, v1 = equal()
|
| 117 |
+
if !matched {
|
| 118 |
+
fmt.Printf("Time %d (%s) and %d (%s): %s\t %X != %X\n",
|
| 119 |
+
c[0].file.time, c[0].file.fname,
|
| 120 |
+
t1, c[1].file.fname, offender,
|
| 121 |
+
v0, v1)
|
| 122 |
+
args.Mismatch_n--
|
| 123 |
+
if( args.Mismatch_n<=0 ) { break }
|
| 124 |
+
}
|
| 125 |
+
if !more {
|
| 126 |
+
fmt.Println("EOF")
|
| 127 |
+
break
|
| 128 |
+
}
|
| 129 |
+
}
|
| 130 |
+
}
|
| 131 |
+
|
| 132 |
+
func Compare( fnames []string, sname string, args CmpArgs ) {
|
| 133 |
+
d,_ := cmpReadin( fnames, sname )
|
| 134 |
+
defer d[0].file.Close()
|
| 135 |
+
defer d[1].file.Close()
|
| 136 |
+
mismatch := false
|
| 137 |
+
d0Names := []string{ d[0].signal.alias }
|
| 138 |
+
d1Names := []string{ d[1].signal.alias }
|
| 139 |
+
d[0].file.MoveTo(d[0].data,args.Time0a)
|
| 140 |
+
d[1].file.MoveTo(d[1].data,args.Time0b)
|
| 141 |
+
if args.Ignore_rst {
|
| 142 |
+
for k:=0; k<len(d); k++ {
|
| 143 |
+
d[k].resets=d[k].data.GetAll("rst",false)
|
| 144 |
+
}
|
| 145 |
+
if d[0].resets!=nil {
|
| 146 |
+
fmt.Println("rst signals found")
|
| 147 |
+
}
|
| 148 |
+
}
|
| 149 |
+
more := true
|
| 150 |
+
for more {
|
| 151 |
+
more = more && d[0].file.NextChangeIn( d[0].data, d0Names )
|
| 152 |
+
more = more && d[1].file.NextChangeIn( d[1].data, d1Names )
|
| 153 |
+
if args.Ignore_rst {
|
| 154 |
+
if in_reset(&d[0]) || in_reset(&d[1]) {
|
| 155 |
+
mv_reset(&d[0])
|
| 156 |
+
mv_reset(&d[1])
|
| 157 |
+
}
|
| 158 |
+
}
|
| 159 |
+
mismatch = d[0].signal.Value != d[1].signal.Value
|
| 160 |
+
if mismatch {
|
| 161 |
+
fmt.Printf("Mismatch at times %d (%s) and %d (%s)\n\t%X != %X\n",
|
| 162 |
+
d[0].file.time, d[0].file.fname,
|
| 163 |
+
d[1].file.time, d[1].file.fname,
|
| 164 |
+
d[0].signal.Value, d[1].signal.Value )
|
| 165 |
+
args.Mismatch_n--
|
| 166 |
+
if( args.Mismatch_n<=0 ) { break }
|
| 167 |
+
}
|
| 168 |
+
}
|
| 169 |
+
if !mismatch {
|
| 170 |
+
fmt.Println("No differences found")
|
| 171 |
+
}
|
| 172 |
+
}
|
| 173 |
+
|
| 174 |
+
// Open the VCD files, get the VCD signal information and
|
| 175 |
+
// find the required signal to compare. Caller must close the files
|
| 176 |
+
func cmpReadin( fnames []string, sname string ) ([2]cmpData,[2]cmpData) {
|
| 177 |
+
var c,r [2]cmpData // compare and reset signals
|
| 178 |
+
|
| 179 |
+
for k:=0; k<2; k++ {
|
| 180 |
+
c[k].file = &LnFile{}
|
| 181 |
+
if !strings.HasSuffix(fnames[k],".vcd") {
|
| 182 |
+
fnames[k] += ".vcd"
|
| 183 |
+
}
|
| 184 |
+
c[k].file.Open(fnames[k])
|
| 185 |
+
c[k].data = GetSignals(c[k].file)
|
| 186 |
+
c[k].signal=getOne(c[k],sname, true)
|
| 187 |
+
r[k].signal=getOne(c[k],"rst", false)
|
| 188 |
+
}
|
| 189 |
+
return c,r
|
| 190 |
+
}
|
| 191 |
+
|
| 192 |
+
func getOne( cd cmpData, sname string, must bool ) *VCDSignal {
|
| 193 |
+
matchScope := strings.Index(sname,".")>-1
|
| 194 |
+
all := cd.data.GetAll(sname, matchScope)
|
| 195 |
+
if all == nil {
|
| 196 |
+
if must {
|
| 197 |
+
fmt.Println("Cannot find any signal named",sname,"in",cd.file.fname)
|
| 198 |
+
os.Exit(1)
|
| 199 |
+
}
|
| 200 |
+
return nil
|
| 201 |
+
}
|
| 202 |
+
if len(all)>1 {
|
| 203 |
+
fmt.Println("Found multiple signals named similarly to",sname)
|
| 204 |
+
for _,k := range all {
|
| 205 |
+
fmt.Println("\t",k.Name)
|
| 206 |
+
}
|
| 207 |
+
fmt.Println("Please specify the name better")
|
| 208 |
+
os.Exit(1)
|
| 209 |
+
}
|
| 210 |
+
fmt.Println("Found",all[0].FullName(), "in", cd.file.fname)
|
| 211 |
+
return all[0]
|
| 212 |
+
}
|
snapshots/jotego_jtcores_pr1270/modules/jtframe/src/jtutil/vcd/lnfile.go
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/* This file is part of JTCORES.
|
| 2 |
+
JTFRAME program is free software: you can redistribute it and/or modify
|
| 3 |
+
it under the terms of the GNU General Public License as published by
|
| 4 |
+
the Free Software Foundation, either version 3 of the License, or
|
| 5 |
+
(at your option) any later version.
|
| 6 |
+
|
| 7 |
+
JTFRAME program is distributed in the hope that it will be useful,
|
| 8 |
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
| 9 |
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
| 10 |
+
GNU General Public License for more details.
|
| 11 |
+
|
| 12 |
+
You should have received a copy of the GNU General Public License
|
| 13 |
+
along with JTFRAME. If not, see <http://www.gnu.org/licenses/>.
|
| 14 |
+
|
| 15 |
+
Author: Jose Tejada Gomez. Twitter: @topapate
|
| 16 |
+
Date: 4-1-2025 */
|
| 17 |
+
|
| 18 |
+
package vcd
|
| 19 |
+
|
| 20 |
+
import (
|
| 21 |
+
"bufio"
|
| 22 |
+
"log"
|
| 23 |
+
"os"
|
| 24 |
+
)
|
| 25 |
+
|
| 26 |
+
type LnFile struct{
|
| 27 |
+
f *os.File
|
| 28 |
+
line int // line count
|
| 29 |
+
scn *bufio.Scanner
|
| 30 |
+
time uint64
|
| 31 |
+
fname string
|
| 32 |
+
}
|
| 33 |
+
|
| 34 |
+
func (ln *LnFile) Open(fname string) {
|
| 35 |
+
var e error
|
| 36 |
+
ln.f, e = os.Open(fname)
|
| 37 |
+
if e != nil {
|
| 38 |
+
log.Fatal(e)
|
| 39 |
+
}
|
| 40 |
+
ln.fname=fname
|
| 41 |
+
ln.scn = bufio.NewScanner(ln.f)
|
| 42 |
+
ln.line = 0
|
| 43 |
+
}
|
| 44 |
+
|
| 45 |
+
func (ln *LnFile) Scan() bool {
|
| 46 |
+
if ln.scn.Scan() {
|
| 47 |
+
ln.line++
|
| 48 |
+
if ln.scn.Err()!=nil {
|
| 49 |
+
log.Fatal(ln.scn.Err())
|
| 50 |
+
}
|
| 51 |
+
return true
|
| 52 |
+
} else {
|
| 53 |
+
return false
|
| 54 |
+
}
|
| 55 |
+
}
|
| 56 |
+
|
| 57 |
+
func (ln *LnFile) Close() {
|
| 58 |
+
if ln.f != nil {
|
| 59 |
+
ln.f.Close()
|
| 60 |
+
}
|
| 61 |
+
}
|
| 62 |
+
|
| 63 |
+
func (ln *LnFile) Time() uint64 {
|
| 64 |
+
return ln.time
|
| 65 |
+
}
|
| 66 |
+
|
| 67 |
+
func (ln *LnFile) Text() string {
|
| 68 |
+
return ln.scn.Text()
|
| 69 |
+
}
|
| 70 |
+
|
snapshots/jotego_jtcores_pr1270/modules/jtframe/src/jtutil/vcd/state.go
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/* This file is part of JTCORES.
|
| 2 |
+
JTFRAME program is free software: you can redistribute it and/or modify
|
| 3 |
+
it under the terms of the GNU General Public License as published by
|
| 4 |
+
the Free Software Foundation, either version 3 of the License, or
|
| 5 |
+
(at your option) any later version.
|
| 6 |
+
|
| 7 |
+
JTFRAME program is distributed in the hope that it will be useful,
|
| 8 |
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
| 9 |
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
| 10 |
+
GNU General Public License for more details.
|
| 11 |
+
|
| 12 |
+
You should have received a copy of the GNU General Public License
|
| 13 |
+
along with JTFRAME. If not, see <http://www.gnu.org/licenses/>.
|
| 14 |
+
|
| 15 |
+
Author: Jose Tejada Gomez. Twitter: @topapate
|
| 16 |
+
Date: 4-1-2025 */
|
| 17 |
+
|
| 18 |
+
package vcd
|
| 19 |
+
|
| 20 |
+
import(
|
| 21 |
+
"fmt"
|
| 22 |
+
"strings"
|
| 23 |
+
"sort"
|
| 24 |
+
)
|
| 25 |
+
|
| 26 |
+
type SimState struct{
|
| 27 |
+
data VCDData
|
| 28 |
+
ram []byte
|
| 29 |
+
}
|
| 30 |
+
|
| 31 |
+
type MAMEState struct{
|
| 32 |
+
data NameValue
|
| 33 |
+
mask NameValue
|
| 34 |
+
alias mameAlias
|
| 35 |
+
ram []byte
|
| 36 |
+
}
|
| 37 |
+
|
| 38 |
+
type mameAlias map[string]*VCDSignal
|
| 39 |
+
type NameValue map[string]uint64
|
| 40 |
+
|
| 41 |
+
func (st MAMEState)validate(name string) bool {
|
| 42 |
+
_, valid := st.data[name]
|
| 43 |
+
return valid
|
| 44 |
+
}
|
| 45 |
+
|
| 46 |
+
func (mame_st *MAMEState) get_sorted_name_indexes() (names []string) {
|
| 47 |
+
names = make([]string,len(mame_st.data))
|
| 48 |
+
k := 0
|
| 49 |
+
for n,_ := range mame_st.data {
|
| 50 |
+
names[k]=n
|
| 51 |
+
k++
|
| 52 |
+
}
|
| 53 |
+
sort.Slice(names,func(i,j int) bool { return strings.Compare(names[i],names[j])<0})
|
| 54 |
+
return names
|
| 55 |
+
}
|
| 56 |
+
|
| 57 |
+
func (mame_st *MAMEState) print_registers(all_names []string) {
|
| 58 |
+
for _,name := range all_names {
|
| 59 |
+
format := "%-2s=0x%X\n"
|
| 60 |
+
if name=="frame_cnt" {
|
| 61 |
+
format = "%-2s=%d\n"
|
| 62 |
+
}
|
| 63 |
+
fmt.Printf( format, name, mame_st.data[name] )
|
| 64 |
+
}
|
| 65 |
+
}
|
snapshots/jotego_jtcores_pr1270/modules/jtframe/src/jtutil/vcd/vcd2hex.go
ADDED
|
@@ -0,0 +1,102 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/* This file is part of JTCORES.
|
| 2 |
+
JTFRAME program is free software: you can redistribute it and/or modify
|
| 3 |
+
it under the terms of the GNU General Public License as published by
|
| 4 |
+
the Free Software Foundation, either version 3 of the License, or
|
| 5 |
+
(at your option) any later version.
|
| 6 |
+
|
| 7 |
+
JTFRAME program is distributed in the hope that it will be useful,
|
| 8 |
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
| 9 |
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
| 10 |
+
GNU General Public License for more details.
|
| 11 |
+
|
| 12 |
+
You should have received a copy of the GNU General Public License
|
| 13 |
+
along with JTFRAME. If not, see <http://www.gnu.org/licenses/>.
|
| 14 |
+
|
| 15 |
+
Author: Jose Tejada Gomez. Twitter: @topapate
|
| 16 |
+
Date: 4-1-2025 */
|
| 17 |
+
|
| 18 |
+
package vcd
|
| 19 |
+
|
| 20 |
+
import (
|
| 21 |
+
"fmt"
|
| 22 |
+
"text/template"
|
| 23 |
+
"os"
|
| 24 |
+
)
|
| 25 |
+
|
| 26 |
+
// Creates a hex file to be used in
|
| 27 |
+
// verilog and the accompanying verilog file
|
| 28 |
+
// to read it
|
| 29 |
+
func (this *LnFile) DumpHex(ss VCDData, fname string) (e error) {
|
| 30 |
+
f, e := os.Create(fname + ".bin"); if e!=nil { return e }
|
| 31 |
+
lines := 0
|
| 32 |
+
tbw := 64
|
| 33 |
+
outputs := make([]*VCDSignal, len(ss))
|
| 34 |
+
k := 0
|
| 35 |
+
for _, each := range ss {
|
| 36 |
+
outputs[k] = each
|
| 37 |
+
k++
|
| 38 |
+
tbw += each.MSB - each.LSB + 1
|
| 39 |
+
}
|
| 40 |
+
var t0 uint64
|
| 41 |
+
set_t0 := true
|
| 42 |
+
for this.NextVCD(ss) {
|
| 43 |
+
if set_t0 {
|
| 44 |
+
t0 = this.time
|
| 45 |
+
set_t0 = false
|
| 46 |
+
}
|
| 47 |
+
fmt.Fprintf(f, "%064b", (this.time-t0)/1000 ) // convert to ns
|
| 48 |
+
for _, each := range outputs {
|
| 49 |
+
fms := fmt.Sprintf("%%0%db", each.MSB-each.LSB+1)
|
| 50 |
+
fmt.Fprintf(f, fms, each.Value)
|
| 51 |
+
}
|
| 52 |
+
fmt.Fprintf(f,"\n")
|
| 53 |
+
lines++
|
| 54 |
+
}
|
| 55 |
+
f.Close()
|
| 56 |
+
t := `module vcd_{{ .Name }}(
|
| 57 |
+
input clk,
|
| 58 |
+
{{ range .Outputs -}}
|
| 59 |
+
output {{ if .MSB }}[{{.MSB}}:{{.LSB}}]{{ end }} {{ .Name }},
|
| 60 |
+
{{ end }}output reg eof=0
|
| 61 |
+
);
|
| 62 |
+
reg [{{.TBW}}-1:0] data[0:{{.Lines}}-1];
|
| 63 |
+
wire [63:0] vcd_time;
|
| 64 |
+
integer idx=0;
|
| 65 |
+
|
| 66 |
+
initial $readmemb("{{.Name}}.bin",data);
|
| 67 |
+
assign {vcd_time{{ range .Outputs }},{{.Name}}{{end}}} = data[idx];
|
| 68 |
+
|
| 69 |
+
always @(posedge clk) begin
|
| 70 |
+
if( !eof ) begin
|
| 71 |
+
if( $time > vcd_time ) idx <= idx+1;
|
| 72 |
+
if( idx=={{.Lines}}-1 ) begin
|
| 73 |
+
eof <= 1;
|
| 74 |
+
$display("{{.Name}} data completely parsed");
|
| 75 |
+
end
|
| 76 |
+
end
|
| 77 |
+
end
|
| 78 |
+
endmodule
|
| 79 |
+
`
|
| 80 |
+
info := struct {
|
| 81 |
+
Name string
|
| 82 |
+
TBW, Lines int
|
| 83 |
+
Outputs []*VCDSignal
|
| 84 |
+
}{
|
| 85 |
+
Name: fname,
|
| 86 |
+
TBW: tbw,
|
| 87 |
+
Lines: lines,
|
| 88 |
+
Outputs: outputs,
|
| 89 |
+
}
|
| 90 |
+
f, e = os.Create(fname + ".v")
|
| 91 |
+
defer f.Close()
|
| 92 |
+
if e!=nil { return e }
|
| 93 |
+
to, e := template.New(fname).Parse(t); if e!=nil { return e }
|
| 94 |
+
return to.Execute(f, info)
|
| 95 |
+
}
|
| 96 |
+
|
| 97 |
+
func must(e error) {
|
| 98 |
+
if e != nil {
|
| 99 |
+
fmt.Println(e)
|
| 100 |
+
os.Exit(1)
|
| 101 |
+
}
|
| 102 |
+
}
|
snapshots/jotego_jtcores_pr1270/modules/jtframe/src/jtutil/vcd/vcd_cmd.go
ADDED
|
@@ -0,0 +1,816 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/* This file is part of JTCORES.
|
| 2 |
+
JTFRAME program is free software: you can redistribute it and/or modify
|
| 3 |
+
it under the terms of the GNU General Public License as published by
|
| 4 |
+
the Free Software Foundation, either version 3 of the License, or
|
| 5 |
+
(at your option) any later version.
|
| 6 |
+
|
| 7 |
+
JTFRAME program is distributed in the hope that it will be useful,
|
| 8 |
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
| 9 |
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
| 10 |
+
GNU General Public License for more details.
|
| 11 |
+
|
| 12 |
+
You should have received a copy of the GNU General Public License
|
| 13 |
+
along with JTFRAME. If not, see <http://www.gnu.org/licenses/>.
|
| 14 |
+
|
| 15 |
+
Author: Jose Tejada Gomez. Twitter: @topapate
|
| 16 |
+
Date: 4-1-2025 */
|
| 17 |
+
|
| 18 |
+
package vcd
|
| 19 |
+
|
| 20 |
+
import(
|
| 21 |
+
"bufio"
|
| 22 |
+
"fmt"
|
| 23 |
+
"log"
|
| 24 |
+
"os"
|
| 25 |
+
"sort"
|
| 26 |
+
"slices"
|
| 27 |
+
"strings"
|
| 28 |
+
"strconv"
|
| 29 |
+
"github.com/PaesslerAG/gval"
|
| 30 |
+
)
|
| 31 |
+
|
| 32 |
+
const CMD_HELP=`
|
| 33 |
+
a,alias links a MAME variable name with a signal name in the VCD
|
| 34 |
+
alias mame-name=vcd-name declares an alias
|
| 35 |
+
alias clear deletes all aliases
|
| 36 |
+
alias -foo deletes the alias "foo"
|
| 37 |
+
d,diff show differences between MAME and simulation at current time
|
| 38 |
+
ds,display display simulation signals at current time
|
| 39 |
+
dt,display-trace display MAME trace values at current time
|
| 40 |
+
f,frame #number advances the simulation upto the given frame
|
| 41 |
+
g,go compare MAME and simulation until a discrepancy cannot be resolved
|
| 42 |
+
?,help produces this help screen
|
| 43 |
+
h,hierarchy shows the signal hierarchy in the simulation
|
| 44 |
+
i,ignore foo boo ignores the given MAME variables in comparison. Shows the
|
| 45 |
+
list of ignored variables if called without names
|
| 46 |
+
mask name FF sets bit masks for signals. Bits set at 1 will be ignored.
|
| 47 |
+
match-vcd moves MAME forward until it matches simulation vcd
|
| 48 |
+
match-trace moves the simulation forward until it matches MAME trace
|
| 49 |
+
mt,mt-trace foo moves MAME forward until the given condition is met
|
| 50 |
+
start hex numbers with $ for comparison
|
| 51 |
+
mv,mv-vcd foo moves simulation forward until the given condition is met
|
| 52 |
+
p,print evaluates an expression. Use to test conditions
|
| 53 |
+
q,quit quits the program
|
| 54 |
+
.,source foo executes the commands in the given file
|
| 55 |
+
s,step forwards simulation by one relevant change
|
| 56 |
+
set vcd-name=value alters the value of a simulation signal
|
| 57 |
+
st,step-trace forwards MAME trace by one relevant change`
|
| 58 |
+
|
| 59 |
+
// keep making this class bigger as refactoring progress
|
| 60 |
+
type Comparator struct{
|
| 61 |
+
alu_busy, str_busy, stack_busy *VCDSignal
|
| 62 |
+
kmax int
|
| 63 |
+
}
|
| 64 |
+
|
| 65 |
+
func NewComparator(ss VCDData) Comparator {
|
| 66 |
+
var cmp Comparator
|
| 67 |
+
cmp.alu_busy = ss.Get(find_similar( "alu_busy", ss ))
|
| 68 |
+
cmp.str_busy = ss.Get(find_similar( "str_busy", ss ))
|
| 69 |
+
cmp.stack_busy = ss.Get(find_similar( "stack_busy", ss ))
|
| 70 |
+
cmp.kmax = 4
|
| 71 |
+
return cmp
|
| 72 |
+
}
|
| 73 |
+
|
| 74 |
+
func Prompt( vcd, trace *LnFile, ss VCDData, mame_alias mameAlias ) {
|
| 75 |
+
fses, e := os.Create("trace.ses") // echo all session commands to a file
|
| 76 |
+
defer fses.Close()
|
| 77 |
+
must(e)
|
| 78 |
+
// Read from stdin initially
|
| 79 |
+
nested := make([]*bufio.Scanner,1)
|
| 80 |
+
nested[0] = bufio.NewScanner(os.Stdin)
|
| 81 |
+
scn := nested[0]
|
| 82 |
+
pc_name := find_similar( "pc", ss)
|
| 83 |
+
cmp := NewComparator(ss)
|
| 84 |
+
|
| 85 |
+
scope := findCommonScope(ss)
|
| 86 |
+
fmt.Printf("At scope %s\n",scope)
|
| 87 |
+
hier := GenerateHierarchy(ss)
|
| 88 |
+
mame_st := &MAMEState{ alias: mame_alias, mask: make(NameValue) }
|
| 89 |
+
sim_st := &SimState{ data: ss }
|
| 90 |
+
ignore := newBoolSet(mame_st)
|
| 91 |
+
|
| 92 |
+
cmd_diff := func() {
|
| 93 |
+
if diff( mame_st, fmt.Sprintf("trace at %d - vcd time %s",trace.line,formatTime(vcd.time)), true, ignore )==0 {
|
| 94 |
+
fmt.Printf("No differences\n")
|
| 95 |
+
} else {
|
| 96 |
+
extra := func( m, s,f string ) {
|
| 97 |
+
mame_pc,_ := mame_st.data[m]
|
| 98 |
+
p := ss.Get(s)
|
| 99 |
+
var vcd_pc uint64
|
| 100 |
+
if p!=nil { vcd_pc=p.Value }
|
| 101 |
+
if mame_pc!=0 || vcd_pc!=0 {
|
| 102 |
+
fmt.Printf("\t%s="+f+" <-> "+f+"\n",m,mame_pc,vcd_pc)
|
| 103 |
+
}
|
| 104 |
+
}
|
| 105 |
+
extra("PC",pc_name,"%X")
|
| 106 |
+
extra("frame_cnt","TOP.game_test.frame_cnt","'d%d")
|
| 107 |
+
}
|
| 108 |
+
}
|
| 109 |
+
|
| 110 |
+
prompt_loop:
|
| 111 |
+
for {
|
| 112 |
+
if( nested[0]==scn ) { fmt.Printf("> ") }
|
| 113 |
+
if !scn.Scan() || scn.Err()!=nil {
|
| 114 |
+
if len(nested)>1 {
|
| 115 |
+
scn = nested[ len(nested)-2 ]
|
| 116 |
+
nested = nested[0:len(nested)-1]
|
| 117 |
+
continue
|
| 118 |
+
}
|
| 119 |
+
break
|
| 120 |
+
}
|
| 121 |
+
lt := scn.Text()
|
| 122 |
+
fmt.Fprintln(fses,lt)
|
| 123 |
+
if k:=strings.Index(lt,"#"); k!=-1 { lt=lt[0:k] }
|
| 124 |
+
tokens := strings.Fields(lt)
|
| 125 |
+
if len(tokens)==0 { continue }
|
| 126 |
+
if( nested[0]!=scn ) { fmt.Println(">",lt) } // echo if we are parsing a file
|
| 127 |
+
switch tokens[0] {
|
| 128 |
+
case "g","go": cmp.searchDiff( vcd, trace, sim_st, mame_st, ignore )
|
| 129 |
+
case "ds","display": {
|
| 130 |
+
var t []string
|
| 131 |
+
if len(tokens)>1 { t = tokens[1:]}
|
| 132 |
+
display( t, vcd, trace, sim_st.data, scope )
|
| 133 |
+
}
|
| 134 |
+
case "d","diff": cmd_diff()
|
| 135 |
+
case "dt","display-trace": display_trace(mame_st,trace)
|
| 136 |
+
case "a","alias": {
|
| 137 |
+
if len(tokens)==1 {
|
| 138 |
+
for k, each := range mame_st.alias {
|
| 139 |
+
fmt.Printf("%s -> %s.%s\n",k,each.Scope, each.Name)
|
| 140 |
+
}
|
| 141 |
+
fmt.Printf("\nUse alias clear to delete all aliases\n")
|
| 142 |
+
fmt.Printf("Use alias mame-name=vcd-name to declare a new alias")
|
| 143 |
+
fmt.Printf("Use alias -name to delete one alias\n")
|
| 144 |
+
} else {
|
| 145 |
+
if tokens[1]=="clear" {
|
| 146 |
+
mame_st.alias = make(mameAlias)
|
| 147 |
+
} else {
|
| 148 |
+
parseAlias( tokens[1:], sim_st.data, mame_st.alias )
|
| 149 |
+
}
|
| 150 |
+
}
|
| 151 |
+
}
|
| 152 |
+
case "c","concat": {
|
| 153 |
+
if len(tokens)!=3 {
|
| 154 |
+
fmt.Println("Wrong arguments. Use cat main-signal appended-signal")
|
| 155 |
+
break
|
| 156 |
+
}
|
| 157 |
+
|
| 158 |
+
p1 := ss.Get(tokens[1])
|
| 159 |
+
p2 := ss.Get(tokens[2])
|
| 160 |
+
if p1==nil {
|
| 161 |
+
fmt.Printf("Cannot find %s\n",tokens[1])
|
| 162 |
+
break
|
| 163 |
+
}
|
| 164 |
+
if p2==nil {
|
| 165 |
+
fmt.Printf("Cannot find %s\n",tokens[2])
|
| 166 |
+
break
|
| 167 |
+
}
|
| 168 |
+
p1.Concat.p = p2
|
| 169 |
+
p1.Concat.at = p1.MSB+1
|
| 170 |
+
}
|
| 171 |
+
case "f", "frame": {
|
| 172 |
+
if len(tokens)!=2 {
|
| 173 |
+
fmt.Println("Wrong arguments. Use frame <number>")
|
| 174 |
+
break
|
| 175 |
+
}
|
| 176 |
+
limit,_ := strconv.ParseUint(tokens[1],0,64)
|
| 177 |
+
mvFrame(vcd,sim_st, uint64(limit) )
|
| 178 |
+
}
|
| 179 |
+
case "h","hierarchy": {
|
| 180 |
+
fmt.Printf("VCD at line %d (time %d ns)\n", vcd.line, vcd.time/1000)
|
| 181 |
+
hier.Dump("")
|
| 182 |
+
}
|
| 183 |
+
case "i","ignore": { // ignore mame-signals, use -name to take it out of the ignore list
|
| 184 |
+
if mame_st.data==nil || len(mame_st.data)==0 {
|
| 185 |
+
fmt.Printf("Start running a trace first\n")
|
| 186 |
+
break
|
| 187 |
+
}
|
| 188 |
+
if len(tokens)==1 {
|
| 189 |
+
ignore.Dump()
|
| 190 |
+
} else {
|
| 191 |
+
ignore.Update(tokens[1:]...)
|
| 192 |
+
}
|
| 193 |
+
}
|
| 194 |
+
case "kmax": {
|
| 195 |
+
if len(tokens)==1 {
|
| 196 |
+
fmt.Printf("KMAX=%d\n",cmp.kmax)
|
| 197 |
+
break
|
| 198 |
+
}
|
| 199 |
+
if len(tokens)!=2 {
|
| 200 |
+
fmt.Println("Wrong arguments. Use kmax <number>")
|
| 201 |
+
break
|
| 202 |
+
}
|
| 203 |
+
aux,_ := strconv.ParseUint(tokens[1],0,64)
|
| 204 |
+
cmp.kmax = int(aux)
|
| 205 |
+
if cmp.kmax < 2 {
|
| 206 |
+
fmt.Printf("Setting KMAX to minimum (2)")
|
| 207 |
+
cmp.kmax=2
|
| 208 |
+
}
|
| 209 |
+
}
|
| 210 |
+
case "mask": {
|
| 211 |
+
if len(tokens)==1 {
|
| 212 |
+
if len(mame_st.mask)==0 {
|
| 213 |
+
fmt.Println("No masks defined")
|
| 214 |
+
} else {
|
| 215 |
+
for k,v := range mame_st.mask {
|
| 216 |
+
fmt.Printf("%-10s %02X\n",k,v)
|
| 217 |
+
}
|
| 218 |
+
}
|
| 219 |
+
break
|
| 220 |
+
}
|
| 221 |
+
if len(tokens)!=3 {
|
| 222 |
+
fmt.Println("Wrong arguments. Use mask <signal name> <hex mask>")
|
| 223 |
+
fmt.Println("Use mask without arguments to show the current mask set")
|
| 224 |
+
break
|
| 225 |
+
}
|
| 226 |
+
mask,e := strconv.ParseUint(tokens[2],16,64)
|
| 227 |
+
if e!=nil {
|
| 228 |
+
fmt.Println(e)
|
| 229 |
+
break
|
| 230 |
+
}
|
| 231 |
+
name := tokens[1]
|
| 232 |
+
_, found := mame_st.data[name]
|
| 233 |
+
if !found {
|
| 234 |
+
fmt.Printf("Signal %s not found in MAME trace\n", name)
|
| 235 |
+
break
|
| 236 |
+
}
|
| 237 |
+
mame_st.mask[name]=mask
|
| 238 |
+
}
|
| 239 |
+
case "q","quit": break prompt_loop
|
| 240 |
+
case "scope": {
|
| 241 |
+
switch len(tokens) {
|
| 242 |
+
case 1: fmt.Println(scope)
|
| 243 |
+
case 2: {
|
| 244 |
+
scope=tokens[1]
|
| 245 |
+
fmt.Println(scope)
|
| 246 |
+
}
|
| 247 |
+
default: fmt.Println("Wrong number of arguments")
|
| 248 |
+
}
|
| 249 |
+
}
|
| 250 |
+
case "p","print": {
|
| 251 |
+
valueMap := HierValues( hier )
|
| 252 |
+
expr := replaceHex(strings.Join(tokens[1:],""))
|
| 253 |
+
v, e := gval.Evaluate( expr, valueMap )
|
| 254 |
+
if e != nil {
|
| 255 |
+
fmt.Println(e)
|
| 256 |
+
break
|
| 257 |
+
}
|
| 258 |
+
fmt.Printf("%s=%X\n",expr,v)
|
| 259 |
+
}
|
| 260 |
+
case "set": {
|
| 261 |
+
if len(tokens)==1 {
|
| 262 |
+
fmt.Println("Use set vcd-name=value ...")
|
| 263 |
+
break
|
| 264 |
+
}
|
| 265 |
+
for k:=1; k<len(tokens); k++ {
|
| 266 |
+
setSignal( tokens[k], hier )
|
| 267 |
+
}
|
| 268 |
+
}
|
| 269 |
+
case ".","source": {
|
| 270 |
+
if len(tokens)==1 {
|
| 271 |
+
fmt.Println("Use `source filename`")
|
| 272 |
+
break
|
| 273 |
+
}
|
| 274 |
+
f,e := os.Open(tokens[1])
|
| 275 |
+
defer f.Close()
|
| 276 |
+
if e!=nil {
|
| 277 |
+
fmt.Println(e)
|
| 278 |
+
break
|
| 279 |
+
}
|
| 280 |
+
scn = bufio.NewScanner(f)
|
| 281 |
+
nested = append( nested, scn )
|
| 282 |
+
break
|
| 283 |
+
}
|
| 284 |
+
case "s","step": {
|
| 285 |
+
cmp.nxVCDChange( vcd, sim_st, mame_st.alias )
|
| 286 |
+
cmd_diff()
|
| 287 |
+
}
|
| 288 |
+
case "st","step-trace": {
|
| 289 |
+
old_data := mame_st.data
|
| 290 |
+
var good bool
|
| 291 |
+
mame_st.data, good = nxTraceChange( trace, mame_st )
|
| 292 |
+
if good {
|
| 293 |
+
mame_st.data.showDiff(old_data)
|
| 294 |
+
}
|
| 295 |
+
}
|
| 296 |
+
case "mv","mv-vcd": {
|
| 297 |
+
if len(tokens)==1 {
|
| 298 |
+
fmt.Printf("Use mvvcd signal=value")
|
| 299 |
+
break
|
| 300 |
+
}
|
| 301 |
+
expr := replaceHex(strings.Join(tokens[1:],""))
|
| 302 |
+
fmt.Println(expr)
|
| 303 |
+
mvVCD( vcd, sim_st, hier, expr, scope)
|
| 304 |
+
}
|
| 305 |
+
case "mt","mv-trace": {
|
| 306 |
+
if len(tokens)==1 {
|
| 307 |
+
fmt.Printf("Use mvtrace signal=value")
|
| 308 |
+
break
|
| 309 |
+
}
|
| 310 |
+
expr := replaceHex(strings.Join(tokens[1:],""))
|
| 311 |
+
fmt.Println(expr)
|
| 312 |
+
if !mvTrace( trace, mame_st, expr ) { break prompt_loop } // EOF
|
| 313 |
+
}
|
| 314 |
+
case "match-vcd": { // moves the trace until it matches the VCD data
|
| 315 |
+
matchVCD( trace, sim_st, mame_st, ignore )
|
| 316 |
+
}
|
| 317 |
+
case "match-trace": { // moves the VCD until it matches MAME data
|
| 318 |
+
cmp.matchTrace( vcd, sim_st, mame_alias, mame_st, ignore )
|
| 319 |
+
}
|
| 320 |
+
case "?","help": {
|
| 321 |
+
fmt.Println(CMD_HELP)
|
| 322 |
+
}
|
| 323 |
+
default: fmt.Println("Unknown command ",tokens[0])
|
| 324 |
+
}
|
| 325 |
+
}
|
| 326 |
+
fmt.Println()
|
| 327 |
+
}
|
| 328 |
+
|
| 329 |
+
func mvTrace( trace *LnFile, mame_st *MAMEState, expr string ) bool {
|
| 330 |
+
l0 := trace.line
|
| 331 |
+
old_data := mame_st.data
|
| 332 |
+
if mame_st.data==nil || len(mame_st.data)==0 {
|
| 333 |
+
mame_st.data = parseTrace(trace.Text())
|
| 334 |
+
}
|
| 335 |
+
for {
|
| 336 |
+
mame_st.data["line"]=uint64(trace.line)
|
| 337 |
+
v, e := gval.Evaluate( expr, mame_st.data )
|
| 338 |
+
if e != nil {
|
| 339 |
+
fmt.Println(e)
|
| 340 |
+
break
|
| 341 |
+
}
|
| 342 |
+
f, fe := v.(bool)
|
| 343 |
+
if fe {
|
| 344 |
+
if f {
|
| 345 |
+
fmt.Printf("Moved by %d lines\n",trace.line-l0)
|
| 346 |
+
mame_st.data.showDiff(old_data)
|
| 347 |
+
break
|
| 348 |
+
}
|
| 349 |
+
} else {
|
| 350 |
+
fmt.Printf("Not a boolean expression\n")
|
| 351 |
+
break
|
| 352 |
+
}
|
| 353 |
+
if !trace.Scan() {
|
| 354 |
+
fmt.Println("Trace EOF")
|
| 355 |
+
return false
|
| 356 |
+
}
|
| 357 |
+
mame_st.data = parseTrace(trace.Text())
|
| 358 |
+
}
|
| 359 |
+
delete(mame_st.data,"line")
|
| 360 |
+
return true
|
| 361 |
+
}
|
| 362 |
+
|
| 363 |
+
func mvFrame( vcd *LnFile, sim_st *SimState, limit uint64 ) {
|
| 364 |
+
var frame *VCDSignal
|
| 365 |
+
for _,each := range sim_st.data {
|
| 366 |
+
if each.Name=="frame_cnt" {
|
| 367 |
+
frame = each
|
| 368 |
+
break
|
| 369 |
+
}
|
| 370 |
+
}
|
| 371 |
+
if sim_st.data==nil {
|
| 372 |
+
fmt.Printf("frame_cnt signal not found in VCD\n")
|
| 373 |
+
return
|
| 374 |
+
}
|
| 375 |
+
for frame.Value<limit && vcd.NextVCD(sim_st.data) { }
|
| 376 |
+
}
|
| 377 |
+
|
| 378 |
+
func mvVCD( vcd *LnFile, sim_st *SimState, hier *Hierarchy, expr string, scope string ) bool {
|
| 379 |
+
t0 := vcd.time
|
| 380 |
+
newline:=false
|
| 381 |
+
for {
|
| 382 |
+
valueMap := HierValues( hier )
|
| 383 |
+
valueMap["line"]=uint64(vcd.line)
|
| 384 |
+
valueMap["time"]=vcd.time
|
| 385 |
+
// add signals in scope
|
| 386 |
+
if scope!="" {
|
| 387 |
+
for _,each := range sim_st.data {
|
| 388 |
+
if each.Scope == scope {
|
| 389 |
+
valueMap[each.Name]=each.Value
|
| 390 |
+
}
|
| 391 |
+
}
|
| 392 |
+
}
|
| 393 |
+
v, e := gval.Evaluate( expr, valueMap )
|
| 394 |
+
if e != nil {
|
| 395 |
+
fmt.Println(e)
|
| 396 |
+
break
|
| 397 |
+
}
|
| 398 |
+
f, fe := v.(bool)
|
| 399 |
+
if fe {
|
| 400 |
+
if f {
|
| 401 |
+
if newline { fmt.Println() }
|
| 402 |
+
fmt.Printf("+ %s\n",formatTime(vcd.time-t0))
|
| 403 |
+
return true
|
| 404 |
+
}
|
| 405 |
+
} else {
|
| 406 |
+
fmt.Printf("Not a boolean expression")
|
| 407 |
+
return false
|
| 408 |
+
}
|
| 409 |
+
if !vcd.NextVCD(sim_st.data) { break }
|
| 410 |
+
if vcd.time-t0>1000000000 { // 1ms
|
| 411 |
+
fmt.Print(".")
|
| 412 |
+
t0=vcd.time
|
| 413 |
+
newline=true
|
| 414 |
+
}
|
| 415 |
+
}
|
| 416 |
+
if newline { fmt.Println() }
|
| 417 |
+
fmt.Println("condition not found")
|
| 418 |
+
return false
|
| 419 |
+
}
|
| 420 |
+
|
| 421 |
+
func find_similar( name string, ss VCDData ) string {
|
| 422 |
+
pc := ""
|
| 423 |
+
for _, each := range ss {
|
| 424 |
+
if strings.ToLower(each.Name)==name {
|
| 425 |
+
pc = each.FullName()
|
| 426 |
+
break
|
| 427 |
+
}
|
| 428 |
+
}
|
| 429 |
+
if pc=="" {
|
| 430 |
+
// Try a partial match at the beginning of the name
|
| 431 |
+
for _, each := range ss {
|
| 432 |
+
if strings.Index( strings.ToLower(each.Name), name )==0 {
|
| 433 |
+
pc = each.FullName()
|
| 434 |
+
break
|
| 435 |
+
}
|
| 436 |
+
}
|
| 437 |
+
}
|
| 438 |
+
if pc=="" {
|
| 439 |
+
fmt.Printf("Could not find a suitable signal as '%s' in the VCD\n",name)
|
| 440 |
+
} else {
|
| 441 |
+
fmt.Printf("Using %s as '%s'\n",name,pc)
|
| 442 |
+
}
|
| 443 |
+
return pc
|
| 444 |
+
}
|
| 445 |
+
|
| 446 |
+
func findCommonScope( ss VCDData ) string {
|
| 447 |
+
scope := ""
|
| 448 |
+
var tokens []string
|
| 449 |
+
first := true
|
| 450 |
+
for _, each := range ss {
|
| 451 |
+
if first {
|
| 452 |
+
scope = each.Scope
|
| 453 |
+
if scope=="" { return "" }
|
| 454 |
+
tokens = strings.Split(scope,".")
|
| 455 |
+
first = false
|
| 456 |
+
continue
|
| 457 |
+
}
|
| 458 |
+
matched := false
|
| 459 |
+
for k:=len(tokens);k!=0;k-- {
|
| 460 |
+
check := strings.Join(tokens[0:k],".")
|
| 461 |
+
check_len := len(check)
|
| 462 |
+
if strings.HasPrefix( each.Scope, check) &&
|
| 463 |
+
( len(each.Scope)==check_len ||
|
| 464 |
+
(len(each.Scope)>check_len && each.Scope[check_len]=='.' )) {
|
| 465 |
+
scope = check
|
| 466 |
+
tokens = strings.Split(scope,".")
|
| 467 |
+
matched = true
|
| 468 |
+
break
|
| 469 |
+
}
|
| 470 |
+
}
|
| 471 |
+
if !matched { return "" }
|
| 472 |
+
}
|
| 473 |
+
return scope
|
| 474 |
+
}
|
| 475 |
+
|
| 476 |
+
// t must be MAME-name=VCD-name
|
| 477 |
+
func parseAlias( t []string, ss VCDData, mame_alias mameAlias ) {
|
| 478 |
+
main_loop:
|
| 479 |
+
for _,each := range t {
|
| 480 |
+
if each[0]=='-' {
|
| 481 |
+
// remove the alias
|
| 482 |
+
delete(mame_alias, each[1:])
|
| 483 |
+
continue
|
| 484 |
+
}
|
| 485 |
+
tokens := strings.Split(each,"=")
|
| 486 |
+
if len(tokens)==0 { continue }
|
| 487 |
+
vcd_name := tokens[0]
|
| 488 |
+
if len(tokens)==2 {
|
| 489 |
+
vcd_name = tokens[1]
|
| 490 |
+
}
|
| 491 |
+
for _,s := range ss {
|
| 492 |
+
if s.Scope+"."+s.Name==vcd_name {
|
| 493 |
+
mame_alias[tokens[0]]=s
|
| 494 |
+
continue main_loop
|
| 495 |
+
}
|
| 496 |
+
if s.Name==vcd_name {
|
| 497 |
+
mame_alias[tokens[0]]=s
|
| 498 |
+
}
|
| 499 |
+
}
|
| 500 |
+
fmt.Printf("Cannot find VCD signal for %s\n",tokens[0])
|
| 501 |
+
}
|
| 502 |
+
}
|
| 503 |
+
|
| 504 |
+
// display all signals, or only the ones with partial string matches in the t []string
|
| 505 |
+
func display( t []string, vcd, trace *LnFile, ss VCDData, scope string ) {
|
| 506 |
+
fmt.Printf("Trace at line %d - VCD at line %d (time %s)\n",
|
| 507 |
+
trace.line, vcd.line, formatTime(vcd.time))
|
| 508 |
+
sorted := make([]struct{
|
| 509 |
+
full string
|
| 510 |
+
p *VCDSignal },len(ss))
|
| 511 |
+
k := 0
|
| 512 |
+
for _, each := range ss {
|
| 513 |
+
sorted[k].p = each
|
| 514 |
+
sorted[k].full = each.FullName()
|
| 515 |
+
k++
|
| 516 |
+
}
|
| 517 |
+
sort.Slice(sorted,func(i,j int)bool {return strings.Compare(sorted[i].full,sorted[j].full)<0})
|
| 518 |
+
for _, each := range sorted {
|
| 519 |
+
print := t==nil
|
| 520 |
+
if !print {
|
| 521 |
+
for _,k := range t {
|
| 522 |
+
if strings.Index(each.full,k)!=-1 {
|
| 523 |
+
print=true
|
| 524 |
+
break
|
| 525 |
+
}
|
| 526 |
+
}
|
| 527 |
+
}
|
| 528 |
+
if print { each.p.Dump() }
|
| 529 |
+
}
|
| 530 |
+
}
|
| 531 |
+
|
| 532 |
+
func parseTrace( s string ) NameValue {
|
| 533 |
+
nv := pase_trace_interrupts(s)
|
| 534 |
+
parse_trace_tokens(s,nv)
|
| 535 |
+
return nv
|
| 536 |
+
}
|
| 537 |
+
|
| 538 |
+
func pase_trace_interrupts(s string) (nv NameValue) {
|
| 539 |
+
nv = make(NameValue)
|
| 540 |
+
if k := strings.Index(s,"*"); k!=-1 {
|
| 541 |
+
rest := s[k:]
|
| 542 |
+
s = s[0:k]
|
| 543 |
+
if k:=strings.Index(rest,"RTI");k!=-1 {
|
| 544 |
+
nv["RTI"]++
|
| 545 |
+
fmt.Printf("MAME RTI\n")
|
| 546 |
+
}
|
| 547 |
+
if k:=strings.Index(rest,"868D");k!=-1 {
|
| 548 |
+
fmt.Printf("MAME enters IRQ\n")
|
| 549 |
+
}
|
| 550 |
+
}
|
| 551 |
+
return nv
|
| 552 |
+
}
|
| 553 |
+
|
| 554 |
+
func parse_trace_tokens( s string, nv NameValue ) {
|
| 555 |
+
for _, token := range strings.Split(s,",") {
|
| 556 |
+
k := strings.Index(token,"=")
|
| 557 |
+
if k==-1 || k+1>len(token) { continue }
|
| 558 |
+
value_text := strings.TrimSpace(token[k+1:])
|
| 559 |
+
v,_ := strconv.ParseInt(value_text,16,64)
|
| 560 |
+
n := token[0:k]
|
| 561 |
+
nv[n] = uint64(v)
|
| 562 |
+
}
|
| 563 |
+
}
|
| 564 |
+
|
| 565 |
+
func diff( st *MAMEState, context string, verbose bool, ignore *boolSet ) int {
|
| 566 |
+
d := 0
|
| 567 |
+
var diffs []string
|
| 568 |
+
for name, value := range st.data {
|
| 569 |
+
if name=="PC" { continue }
|
| 570 |
+
p, _ := st.alias[name]
|
| 571 |
+
if p == nil { continue }
|
| 572 |
+
toignore := ignore.IsSet(name)
|
| 573 |
+
mask, _ := st.mask[name]
|
| 574 |
+
equal := (p.FullValue() | mask) == (value | mask)
|
| 575 |
+
if equal && toignore { // use full value to concatenate data
|
| 576 |
+
ignore.Remove(name) // stops ignoring it
|
| 577 |
+
fmt.Printf("%s taken out of the ignore list\n",name)
|
| 578 |
+
}
|
| 579 |
+
if !equal && !toignore {
|
| 580 |
+
if verbose {
|
| 581 |
+
if diffs==nil { diffs = make([]string,0,1) }
|
| 582 |
+
diffs = append(diffs, name)
|
| 583 |
+
}
|
| 584 |
+
d++
|
| 585 |
+
}
|
| 586 |
+
if p.Name=="irq_bsy" && p.Value==1 { // do not compare during the interrupt interval
|
| 587 |
+
return 0
|
| 588 |
+
}
|
| 589 |
+
}
|
| 590 |
+
if verbose && diffs!=nil {
|
| 591 |
+
if context!="" { fmt.Println(context) }
|
| 592 |
+
fmt.Println("\t MAME - SIM")
|
| 593 |
+
slices.Sort(diffs)
|
| 594 |
+
for _,name := range diffs {
|
| 595 |
+
p,_ := st.alias[name]
|
| 596 |
+
if p==nil { continue }
|
| 597 |
+
fmt.Printf("\t%-4s %4X <-> %4X (%s.%s)\n", name, st.data[name], p.FullValue(), p.Scope, p.Name )
|
| 598 |
+
}
|
| 599 |
+
}
|
| 600 |
+
return d
|
| 601 |
+
}
|
| 602 |
+
|
| 603 |
+
func (cmp *Comparator) nxVCDChange( file *LnFile, sim_st *SimState, mame_alias mameAlias ) (int,bool) {
|
| 604 |
+
l0 := file.line
|
| 605 |
+
changed := false
|
| 606 |
+
irq_bsy := sim_st.data.Get("TOP.game_test.u_game.u_game.u_main.u_cpu.u_ctrl.u_ucode.irq_bsy")
|
| 607 |
+
was_irq := irq_bsy!=nil && irq_bsy.Value!=0
|
| 608 |
+
was_stack := cmp.stack_busy!=nil && cmp.stack_busy.Value!=0
|
| 609 |
+
was_alu := cmp.alu_busy!=nil && cmp.alu_busy.Value!=0
|
| 610 |
+
was_str := cmp.str_busy!=nil && cmp.str_busy.Value!=0
|
| 611 |
+
for file.Scan() {
|
| 612 |
+
txt := file.Text()
|
| 613 |
+
if txt[0]=='#' {
|
| 614 |
+
file.time, _ = strconv.ParseUint( txt[1:],10,64 )
|
| 615 |
+
if changed {
|
| 616 |
+
break
|
| 617 |
+
} else {
|
| 618 |
+
continue
|
| 619 |
+
}
|
| 620 |
+
}
|
| 621 |
+
a, v := parseValue(txt)
|
| 622 |
+
assign( a, v, sim_st.data )
|
| 623 |
+
p,_ := sim_st.data[a]
|
| 624 |
+
if p==nil {
|
| 625 |
+
log.Fatal("Error: bad pointer to VCDSignal\n")
|
| 626 |
+
}
|
| 627 |
+
// Skip busy sections
|
| 628 |
+
if cmp.alu_busy!=nil && cmp.alu_busy.Value==1 {
|
| 629 |
+
was_alu = true
|
| 630 |
+
continue
|
| 631 |
+
} else if was_alu {
|
| 632 |
+
changed = true
|
| 633 |
+
break
|
| 634 |
+
}
|
| 635 |
+
if cmp.str_busy!=nil && cmp.str_busy.Value==1 {
|
| 636 |
+
was_str = true
|
| 637 |
+
continue
|
| 638 |
+
} else if was_str {
|
| 639 |
+
changed = true
|
| 640 |
+
break
|
| 641 |
+
}
|
| 642 |
+
if cmp.stack_busy!=nil && cmp.stack_busy.Value==1 {
|
| 643 |
+
was_stack = true
|
| 644 |
+
continue
|
| 645 |
+
} else if was_stack {
|
| 646 |
+
changed = true
|
| 647 |
+
break
|
| 648 |
+
}
|
| 649 |
+
if irq_bsy!=nil && irq_bsy.Value==1 {
|
| 650 |
+
if !was_irq {
|
| 651 |
+
was_irq=true
|
| 652 |
+
fmt.Println("VCD enters IRQ")
|
| 653 |
+
}
|
| 654 |
+
continue // fly over the interrupt
|
| 655 |
+
} else if was_irq {
|
| 656 |
+
changed = true
|
| 657 |
+
break
|
| 658 |
+
}
|
| 659 |
+
for _,v := range mame_alias {
|
| 660 |
+
if p==v {
|
| 661 |
+
changed = true
|
| 662 |
+
// fmt.Printf("%s=%X\n",p.FullName(),p.Value)
|
| 663 |
+
break
|
| 664 |
+
}
|
| 665 |
+
}
|
| 666 |
+
}
|
| 667 |
+
if !changed {
|
| 668 |
+
fmt.Printf("Reached EOF of VCD file after ")
|
| 669 |
+
}
|
| 670 |
+
return file.line-l0, changed
|
| 671 |
+
}
|
| 672 |
+
|
| 673 |
+
func nxTraceChange( trace *LnFile, mame_st *MAMEState ) (NameValue,bool) {
|
| 674 |
+
// l0 := trace.line
|
| 675 |
+
for trace.Scan() {
|
| 676 |
+
old := mame_st.data
|
| 677 |
+
mame_st.data = parseTrace(trace.Text())
|
| 678 |
+
for name, _ := range mame_st.alias {
|
| 679 |
+
if mame_st.data[name] != old[name] {
|
| 680 |
+
// fmt.Printf(">%s changed\n",name)
|
| 681 |
+
// fmt.Printf("trace +%d lines\n",trace.line-l0)
|
| 682 |
+
return mame_st.data,true
|
| 683 |
+
}
|
| 684 |
+
}
|
| 685 |
+
}
|
| 686 |
+
fmt.Printf("Trace EOF\n")
|
| 687 |
+
return mame_st.data,false
|
| 688 |
+
}
|
| 689 |
+
|
| 690 |
+
func (cmp *Comparator)searchDiff( vcd,trace *LnFile, sim_st *SimState, mame_st *MAMEState,
|
| 691 |
+
ignore *boolSet ) {
|
| 692 |
+
if mame_st.data==nil || len(mame_st.data)==0 {
|
| 693 |
+
trace.Scan()
|
| 694 |
+
mame_st.data = parseTrace(trace.Text())
|
| 695 |
+
}
|
| 696 |
+
|
| 697 |
+
var good bool
|
| 698 |
+
tvcd := vcd.time
|
| 699 |
+
var div_time uint64
|
| 700 |
+
main_loop:
|
| 701 |
+
for {
|
| 702 |
+
mame_st.data, good = nxTraceChange( trace, mame_st )
|
| 703 |
+
if !good { break }
|
| 704 |
+
div_time = vcd.time
|
| 705 |
+
for k:=0;k<cmp.kmax;k++ {
|
| 706 |
+
if diff( mame_st, "", false, ignore )==0 { continue main_loop }
|
| 707 |
+
_, good := cmp.nxVCDChange( vcd, sim_st, mame_st.alias )
|
| 708 |
+
if !good { break }
|
| 709 |
+
// fmt.Printf("+%d VCD lines\n",lines)
|
| 710 |
+
}
|
| 711 |
+
if diff( mame_st, "", false, ignore )!=0 {
|
| 712 |
+
break
|
| 713 |
+
}
|
| 714 |
+
}
|
| 715 |
+
fmt.Printf("+%s\n", formatTime(vcd.time-tvcd))
|
| 716 |
+
// display the difference
|
| 717 |
+
diff( mame_st, fmt.Sprintf("trace at %d - vcd time %s (diverged at %s)",
|
| 718 |
+
trace.line,formatTime(vcd.time), formatTime(div_time)), true, ignore )
|
| 719 |
+
}
|
| 720 |
+
|
| 721 |
+
func matchVCD( trace *LnFile, sim_st *SimState, mame_st *MAMEState, ignore *boolSet ) bool {
|
| 722 |
+
if mame_st.data==nil || len(mame_st.data)==0 {
|
| 723 |
+
trace.Scan()
|
| 724 |
+
mame_st.data = parseTrace(trace.Text())
|
| 725 |
+
}
|
| 726 |
+
line0 := trace.line
|
| 727 |
+
var good, matched bool
|
| 728 |
+
for {
|
| 729 |
+
mame_st.data, good = nxTraceChange( trace, mame_st )
|
| 730 |
+
matched = diff( mame_st, "", false, ignore )==0
|
| 731 |
+
if !good || matched { break }
|
| 732 |
+
}
|
| 733 |
+
// display the difference
|
| 734 |
+
if !matched {
|
| 735 |
+
fmt.Printf("Impossible to match MAME to VCD")
|
| 736 |
+
diff( mame_st, fmt.Sprintf("trace at %d",trace.line), true, ignore )
|
| 737 |
+
} else {
|
| 738 |
+
fmt.Printf("VCD matched by advancing MAME trace(+ %d lines)\n",trace.line-line0)
|
| 739 |
+
}
|
| 740 |
+
return matched
|
| 741 |
+
}
|
| 742 |
+
|
| 743 |
+
func (cmp *Comparator)matchTrace( file *LnFile, sim_st *SimState, mame_alias mameAlias,
|
| 744 |
+
mame_st *MAMEState, ignore *boolSet ) bool {
|
| 745 |
+
var good, matched bool
|
| 746 |
+
total_lines := 0
|
| 747 |
+
time0 := file.time
|
| 748 |
+
for {
|
| 749 |
+
lines := 0
|
| 750 |
+
lines, good = cmp.nxVCDChange( file, sim_st, mame_alias )
|
| 751 |
+
total_lines += lines
|
| 752 |
+
matched = diff( mame_st, "", false, ignore )==0
|
| 753 |
+
if !good || matched { break }
|
| 754 |
+
}
|
| 755 |
+
// display the difference
|
| 756 |
+
if !matched {
|
| 757 |
+
fmt.Printf("Impossible to match VCD to MAME")
|
| 758 |
+
diff( mame_st, fmt.Sprintf("sim at time %d",file.time), true, ignore )
|
| 759 |
+
} else {
|
| 760 |
+
time1 := file.time
|
| 761 |
+
delta := time1-time0
|
| 762 |
+
fmt.Printf("MAME trace matched by advancing the VCD by %d lines (%s)\n",
|
| 763 |
+
total_lines, formatTime(delta))
|
| 764 |
+
}
|
| 765 |
+
return matched
|
| 766 |
+
}
|
| 767 |
+
|
| 768 |
+
|
| 769 |
+
func MakeAlias( trace string, ss VCDData ) mameAlias {
|
| 770 |
+
mame_alias := make(mameAlias)
|
| 771 |
+
tokens := strings.Split(trace,",")
|
| 772 |
+
if len(tokens)==0 { return mame_alias }
|
| 773 |
+
|
| 774 |
+
for _,each := range tokens {
|
| 775 |
+
if len(each)==0 || each[0]=='*' { break }
|
| 776 |
+
k := strings.Index(each,"=")
|
| 777 |
+
if k==-1 { continue }
|
| 778 |
+
name := strings.ToLower(each[0:k])
|
| 779 |
+
if name=="pc" || name=="frame_cnt" { continue } // these are normally hard to match
|
| 780 |
+
var p *VCDSignal
|
| 781 |
+
for _, v := range ss {
|
| 782 |
+
if strings.ToLower(v.Name)==name {
|
| 783 |
+
p = v
|
| 784 |
+
break
|
| 785 |
+
}
|
| 786 |
+
}
|
| 787 |
+
if p==nil {
|
| 788 |
+
fmt.Printf("Cannot alias signal %s\n",name)
|
| 789 |
+
continue
|
| 790 |
+
}
|
| 791 |
+
mame_alias[each[0:k]]=p
|
| 792 |
+
}
|
| 793 |
+
return mame_alias
|
| 794 |
+
}
|
| 795 |
+
|
| 796 |
+
func display_trace(mame_st *MAMEState, trace *LnFile) {
|
| 797 |
+
fmt.Printf("At line %d",trace.line)
|
| 798 |
+
ltxt := trace.Text()
|
| 799 |
+
print_assembler_code(ltxt)
|
| 800 |
+
|
| 801 |
+
names := mame_st.get_sorted_name_indexes()
|
| 802 |
+
if len(names)==0 {
|
| 803 |
+
fmt.Println("\nNo register content in line")
|
| 804 |
+
fmt.Printf("Line: '%s'\n",ltxt)
|
| 805 |
+
return
|
| 806 |
+
}
|
| 807 |
+
mame_st.print_registers(names)
|
| 808 |
+
}
|
| 809 |
+
|
| 810 |
+
func print_assembler_code(line string) {
|
| 811 |
+
if k:=strings.Index(line,"*"); k!=-1 {
|
| 812 |
+
assembler_code := line[k+1:]
|
| 813 |
+
fmt.Println(assembler_code)
|
| 814 |
+
}
|
| 815 |
+
}
|
| 816 |
+
|
snapshots/jotego_jtcores_pr1270/modules/jtframe/src/jtutil/vcd/vcd_cmd_test.go
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
package vcd
|
| 2 |
+
|
| 3 |
+
import(
|
| 4 |
+
"testing"
|
| 5 |
+
)
|
| 6 |
+
|
| 7 |
+
func Test_parseTrace(t *testing.T) {
|
| 8 |
+
match_parse_namevalue("AF=1234",NameValue{"AF":0x1234},t)
|
| 9 |
+
match_parse_namevalue("AF=1234,DE=5678",NameValue{"AF":0x1234,"DE":0x5678},t)
|
| 10 |
+
match_parse_namevalue("AF= 34",NameValue{"AF":0x0034},t)
|
| 11 |
+
match_parse_namevalue("AF= 34,DE= 78",NameValue{"AF":0x0034,"DE":0x0078},t)
|
| 12 |
+
}
|
| 13 |
+
|
| 14 |
+
func match_parse_namevalue(trace string,expected NameValue,t *testing.T) {
|
| 15 |
+
got := parseTrace(trace)
|
| 16 |
+
if len(got)!=len(expected) {
|
| 17 |
+
t.Error("Got wrong number of elements")
|
| 18 |
+
return
|
| 19 |
+
}
|
| 20 |
+
for name,val := range got {
|
| 21 |
+
exp,found := expected[name]
|
| 22 |
+
if !found {
|
| 23 |
+
t.Errorf("Missing value for %s",name)
|
| 24 |
+
return
|
| 25 |
+
}
|
| 26 |
+
if exp != val {
|
| 27 |
+
t.Errorf("Wrong value for %s",name)
|
| 28 |
+
return
|
| 29 |
+
}
|
| 30 |
+
}
|
| 31 |
+
}
|
snapshots/jotego_jtcores_pr1270/modules/jtframe/src/jtutil/vcd/vcd_parser.go
ADDED
|
@@ -0,0 +1,578 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/* This file is part of JTCORES.
|
| 2 |
+
JTFRAME program is free software: you can redistribute it and/or modify
|
| 3 |
+
it under the terms of the GNU General Public License as published by
|
| 4 |
+
the Free Software Foundation, either version 3 of the License, or
|
| 5 |
+
(at your option) any later version.
|
| 6 |
+
|
| 7 |
+
JTFRAME program is distributed in the hope that it will be useful,
|
| 8 |
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
| 9 |
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
| 10 |
+
GNU General Public License for more details.
|
| 11 |
+
|
| 12 |
+
You should have received a copy of the GNU General Public License
|
| 13 |
+
along with JTFRAME. If not, see <http://www.gnu.org/licenses/>.
|
| 14 |
+
|
| 15 |
+
Author: Jose Tejada Gomez. Twitter: @topapate
|
| 16 |
+
Date: 4-1-2025 */
|
| 17 |
+
|
| 18 |
+
package vcd
|
| 19 |
+
|
| 20 |
+
import(
|
| 21 |
+
"fmt"
|
| 22 |
+
"os"
|
| 23 |
+
"regexp"
|
| 24 |
+
"slices"
|
| 25 |
+
"strings"
|
| 26 |
+
"strconv"
|
| 27 |
+
"sort"
|
| 28 |
+
)
|
| 29 |
+
|
| 30 |
+
type VCDSignal struct{
|
| 31 |
+
Scope, Name string
|
| 32 |
+
alias string
|
| 33 |
+
MSB,LSB int // MSB-LSB<=64, so it can fit in Value
|
| 34 |
+
Value, copy uint64
|
| 35 |
+
Concat struct{
|
| 36 |
+
p *VCDSignal // signal to concatenate
|
| 37 |
+
at int // bit position at which concatenation starts
|
| 38 |
+
}
|
| 39 |
+
}
|
| 40 |
+
|
| 41 |
+
type VCDData map[string]*VCDSignal
|
| 42 |
+
type boolSet struct {
|
| 43 |
+
v validator
|
| 44 |
+
set map[string]bool
|
| 45 |
+
}
|
| 46 |
+
|
| 47 |
+
type Hierarchy struct{
|
| 48 |
+
Nested map[string]*Hierarchy
|
| 49 |
+
Signals map[string]*VCDSignal
|
| 50 |
+
}
|
| 51 |
+
|
| 52 |
+
func (bset boolSet) Dump() {
|
| 53 |
+
for k, each := range bset.set {
|
| 54 |
+
if each { fmt.Printf("%s\n",k) }
|
| 55 |
+
}
|
| 56 |
+
}
|
| 57 |
+
|
| 58 |
+
type validator interface {
|
| 59 |
+
validate (name string) bool
|
| 60 |
+
}
|
| 61 |
+
|
| 62 |
+
func newBoolSet(v validator) (*boolSet) {
|
| 63 |
+
return &boolSet{
|
| 64 |
+
v: v,
|
| 65 |
+
set: make(map[string]bool),
|
| 66 |
+
}
|
| 67 |
+
}
|
| 68 |
+
|
| 69 |
+
func (b *boolSet) Update(all_names...string) {
|
| 70 |
+
for _, name := range all_names {
|
| 71 |
+
turnon:= true
|
| 72 |
+
if name[0]=='-' {
|
| 73 |
+
turnon = false
|
| 74 |
+
name=name[1:]
|
| 75 |
+
}
|
| 76 |
+
if !b.v.validate(name) {
|
| 77 |
+
fmt.Printf("Couldn't find %s\n", name)
|
| 78 |
+
continue
|
| 79 |
+
}
|
| 80 |
+
b.set[name]=turnon
|
| 81 |
+
}
|
| 82 |
+
}
|
| 83 |
+
|
| 84 |
+
func (b *boolSet)Remove(all_names... string) {
|
| 85 |
+
for _, name := range all_names {
|
| 86 |
+
b.set[name]=false
|
| 87 |
+
}
|
| 88 |
+
}
|
| 89 |
+
|
| 90 |
+
func (b boolSet)IsSet(name string) bool {
|
| 91 |
+
valid, _ := b.set[name]
|
| 92 |
+
return valid
|
| 93 |
+
}
|
| 94 |
+
|
| 95 |
+
func (this *VCDSignal) Dump() {
|
| 96 |
+
if this.Scope != "" { fmt.Printf("%s.", this.Scope ) }
|
| 97 |
+
fmt.Printf( "%s",this.Name)
|
| 98 |
+
if this.MSB!=0 {
|
| 99 |
+
fmt.Printf("[%d:%d]",this.MSB, this.LSB)
|
| 100 |
+
}
|
| 101 |
+
fmt.Printf("\t = %X", this.Value )
|
| 102 |
+
if this.Concat.p != nil {
|
| 103 |
+
fmt.Printf(" -> %X", this.FullValue())
|
| 104 |
+
}
|
| 105 |
+
// the frame count is shown in decimal too
|
| 106 |
+
if( this.Name == "frame_cnt") {
|
| 107 |
+
fmt.Printf(" ('d%d)",this.Value)
|
| 108 |
+
}
|
| 109 |
+
fmt.Println()
|
| 110 |
+
}
|
| 111 |
+
|
| 112 |
+
func (this *VCDSignal)FullValue() uint64 {
|
| 113 |
+
v := this.Value
|
| 114 |
+
cat := this.Concat
|
| 115 |
+
for cat.p!=nil {
|
| 116 |
+
v = v | (cat.p.Value<<cat.at) // no masking for now
|
| 117 |
+
cat = cat.p.Concat
|
| 118 |
+
}
|
| 119 |
+
return v
|
| 120 |
+
}
|
| 121 |
+
|
| 122 |
+
func (this *VCDSignal)Save() {
|
| 123 |
+
this.copy = this.Value
|
| 124 |
+
}
|
| 125 |
+
|
| 126 |
+
func (this *VCDSignal)Restore() {
|
| 127 |
+
this.Value = this.copy
|
| 128 |
+
}
|
| 129 |
+
|
| 130 |
+
func (this *VCDSignal)FullName() string {
|
| 131 |
+
if this.Scope=="" {
|
| 132 |
+
return this.Name
|
| 133 |
+
} else {
|
| 134 |
+
return this.Scope+"."+this.Name
|
| 135 |
+
}
|
| 136 |
+
}
|
| 137 |
+
|
| 138 |
+
func (this VCDData)Get(name string) *VCDSignal {
|
| 139 |
+
if name=="" { return nil }
|
| 140 |
+
for _,each := range this {
|
| 141 |
+
if each.FullName()==name { return each }
|
| 142 |
+
}
|
| 143 |
+
return nil
|
| 144 |
+
}
|
| 145 |
+
|
| 146 |
+
// gets the scope part of a hierarchinal signal name
|
| 147 |
+
func GetScope( name string ) (string, string) {
|
| 148 |
+
tokens := strings.Split(name,".")
|
| 149 |
+
if len(tokens)==1 {
|
| 150 |
+
return "",name
|
| 151 |
+
}
|
| 152 |
+
return strings.Join(tokens[0:len(tokens)-1],"."), tokens[len(tokens)-1]
|
| 153 |
+
}
|
| 154 |
+
|
| 155 |
+
func (this VCDData)GetAll(name string, matchScope bool) []*VCDSignal {
|
| 156 |
+
if name=="" { return nil }
|
| 157 |
+
r := make([]*VCDSignal,0,1)
|
| 158 |
+
scope,name := GetScope(name)
|
| 159 |
+
for _,each := range this {
|
| 160 |
+
if each.Name==name && (!matchScope || scope==each.Scope) {
|
| 161 |
+
r=append(r,each)
|
| 162 |
+
}
|
| 163 |
+
}
|
| 164 |
+
if len(r) == 0 {
|
| 165 |
+
return nil
|
| 166 |
+
} else {
|
| 167 |
+
return r
|
| 168 |
+
}
|
| 169 |
+
}
|
| 170 |
+
|
| 171 |
+
func RenameRegs( ss VCDData ) {
|
| 172 |
+
// Rename signals for some CPUs
|
| 173 |
+
// fx68k
|
| 174 |
+
for _,each := range ss {
|
| 175 |
+
switch each.Name {
|
| 176 |
+
case "regs68L[0]": each.Name="D0"
|
| 177 |
+
case "regs68L[1]": each.Name="D1"
|
| 178 |
+
case "regs68L[2]": each.Name="D2"
|
| 179 |
+
case "regs68L[3]": each.Name="D3"
|
| 180 |
+
case "regs68L[4]": each.Name="D4"
|
| 181 |
+
case "regs68L[5]": each.Name="D5"
|
| 182 |
+
case "regs68L[6]": each.Name="D6"
|
| 183 |
+
case "regs68L[7]": each.Name="D7"
|
| 184 |
+
|
| 185 |
+
case "regs68H[0]": each.Name="D0H"
|
| 186 |
+
case "regs68H[1]": each.Name="D1H"
|
| 187 |
+
case "regs68H[2]": each.Name="D2H"
|
| 188 |
+
case "regs68H[3]": each.Name="D3H"
|
| 189 |
+
case "regs68H[4]": each.Name="D4H"
|
| 190 |
+
case "regs68H[5]": each.Name="D5H"
|
| 191 |
+
case "regs68H[6]": each.Name="D6H"
|
| 192 |
+
case "regs68H[7]": each.Name="D7H"
|
| 193 |
+
|
| 194 |
+
case "regs68L[8]": each.Name="A0"
|
| 195 |
+
case "regs68L[9]": each.Name="A1"
|
| 196 |
+
case "regs68L[10]": each.Name="A2"
|
| 197 |
+
case "regs68L[11]": each.Name="A3"
|
| 198 |
+
case "regs68L[12]": each.Name="A4"
|
| 199 |
+
case "regs68L[13]": each.Name="A5"
|
| 200 |
+
case "regs68L[14]": each.Name="A6"
|
| 201 |
+
case "regs68L[16]": each.Name="A7"
|
| 202 |
+
|
| 203 |
+
case "regs68H[8]": each.Name="A0H"
|
| 204 |
+
case "regs68H[9]": each.Name="A1H"
|
| 205 |
+
case "regs68H[10]": each.Name="A2H"
|
| 206 |
+
case "regs68H[11]": each.Name="A3H"
|
| 207 |
+
case "regs68H[12]": each.Name="A4H"
|
| 208 |
+
case "regs68H[13]": each.Name="A5H"
|
| 209 |
+
case "regs68H[14]": each.Name="A6H"
|
| 210 |
+
case "regs68H[16]": each.Name="A7H"
|
| 211 |
+
}
|
| 212 |
+
}
|
| 213 |
+
concatHL := func( H,L string ) {
|
| 214 |
+
for _, each := range ss {
|
| 215 |
+
if each.Name==L {
|
| 216 |
+
for _, eachH := range ss {
|
| 217 |
+
if eachH.Name==H && eachH.Scope == each.Scope {
|
| 218 |
+
each.Concat.p = eachH
|
| 219 |
+
each.Concat.at = 16
|
| 220 |
+
}
|
| 221 |
+
}
|
| 222 |
+
}
|
| 223 |
+
}
|
| 224 |
+
}
|
| 225 |
+
concatSeries := func( prefix string ) {
|
| 226 |
+
for k:=0;k<8;k++ {
|
| 227 |
+
L := fmt.Sprintf("%s%d",prefix,k)
|
| 228 |
+
H := fmt.Sprintf("%s%dH",prefix,k)
|
| 229 |
+
concatHL( H, L )
|
| 230 |
+
}
|
| 231 |
+
}
|
| 232 |
+
|
| 233 |
+
concatSeries("D")
|
| 234 |
+
concatSeries("A")
|
| 235 |
+
concatHL("PcH","PcL")
|
| 236 |
+
}
|
| 237 |
+
|
| 238 |
+
func formatTime( t uint64 ) string {
|
| 239 |
+
tpico := t
|
| 240 |
+
t /= 1000 // ignore ps
|
| 241 |
+
if t==0 { return "0 s" }
|
| 242 |
+
o := 0
|
| 243 |
+
units := []string{"ns","us","ms","s"}
|
| 244 |
+
parts := []uint64{0,0,0,0}
|
| 245 |
+
for t>0 && o<4 {
|
| 246 |
+
parts[o] = t%1000
|
| 247 |
+
t/= 1000
|
| 248 |
+
o++
|
| 249 |
+
}
|
| 250 |
+
var s string
|
| 251 |
+
for k:=0;k<o; k++ {
|
| 252 |
+
if s!="" { s=","+s}
|
| 253 |
+
s = fmt.Sprintf("%d%s%s",parts[k],units[k],s)
|
| 254 |
+
}
|
| 255 |
+
s = fmt.Sprintf("%s= %d",s,tpico)
|
| 256 |
+
return s
|
| 257 |
+
}
|
| 258 |
+
|
| 259 |
+
func GenerateHierarchy( ss VCDData ) *Hierarchy {
|
| 260 |
+
// Convert ss to a slice
|
| 261 |
+
signals := make([]*VCDSignal,len(ss))
|
| 262 |
+
k := 0
|
| 263 |
+
for _,each := range ss {
|
| 264 |
+
signals[k] = each
|
| 265 |
+
k++
|
| 266 |
+
}
|
| 267 |
+
// Sort by scope length, then signal name
|
| 268 |
+
sort.Slice(signals,func( i, j int ) bool {
|
| 269 |
+
s := strings.Compare(signals[i].Scope,signals[j].Scope)
|
| 270 |
+
if s==0 {
|
| 271 |
+
return strings.Compare(signals[i].Name,signals[j].Name)<0
|
| 272 |
+
}
|
| 273 |
+
return s<0
|
| 274 |
+
})
|
| 275 |
+
// Create the hierarchy following the sorted list
|
| 276 |
+
return fillHierarchy( signals, "")
|
| 277 |
+
}
|
| 278 |
+
|
| 279 |
+
func fillHierarchy( signals []*VCDSignal, scope string ) *Hierarchy {
|
| 280 |
+
h := &Hierarchy{}
|
| 281 |
+
last := ""
|
| 282 |
+
for k, _ := range signals {
|
| 283 |
+
if signals[k].Scope==scope {
|
| 284 |
+
if h.Signals==nil { h.Signals = make(map[string]*VCDSignal) }
|
| 285 |
+
h.Signals[signals[k].Name]=signals[k]
|
| 286 |
+
continue
|
| 287 |
+
}
|
| 288 |
+
if strings.HasPrefix(signals[k].Scope,scope+".") || scope=="" {
|
| 289 |
+
var nx_scope, nx_full string
|
| 290 |
+
var rest []string
|
| 291 |
+
if scope == "" {
|
| 292 |
+
rest = strings.Split( signals[k].Scope, "." )
|
| 293 |
+
nx_scope = rest[0]
|
| 294 |
+
nx_full = nx_scope
|
| 295 |
+
} else {
|
| 296 |
+
rest = strings.Split( signals[k].Scope[len(scope)+1:], "." )
|
| 297 |
+
nx_scope = rest[0]
|
| 298 |
+
nx_full = scope+"."+nx_scope
|
| 299 |
+
}
|
| 300 |
+
if last != nx_scope {
|
| 301 |
+
nested := fillHierarchy( signals[k:], nx_full )
|
| 302 |
+
if h.Nested == nil { h.Nested = make(map[string]*Hierarchy) }
|
| 303 |
+
h.Nested[nx_scope] = nested
|
| 304 |
+
last = nx_scope
|
| 305 |
+
}
|
| 306 |
+
continue
|
| 307 |
+
}
|
| 308 |
+
break
|
| 309 |
+
}
|
| 310 |
+
return h
|
| 311 |
+
}
|
| 312 |
+
|
| 313 |
+
func (this *Hierarchy) Dump(indent string) {
|
| 314 |
+
i2 := indent+" "
|
| 315 |
+
if len(this.Signals)>0 {
|
| 316 |
+
signals := make([]*VCDSignal,len(this.Signals))
|
| 317 |
+
cnt:=0
|
| 318 |
+
for _,s := range this.Signals {
|
| 319 |
+
signals[cnt] = s
|
| 320 |
+
cnt++
|
| 321 |
+
}
|
| 322 |
+
sort.Slice(signals,func(i,j int) bool {
|
| 323 |
+
return strings.Compare( signals[i].Name, signals[j].Name )<0
|
| 324 |
+
})
|
| 325 |
+
for _, each := range signals{
|
| 326 |
+
fmt.Printf("%s%s (%X)\n",indent,each.Name, each.Value)
|
| 327 |
+
}
|
| 328 |
+
}
|
| 329 |
+
for name,each := range this.Nested {
|
| 330 |
+
fmt.Println(indent+">"+name)
|
| 331 |
+
each.Dump(i2)
|
| 332 |
+
}
|
| 333 |
+
}
|
| 334 |
+
|
| 335 |
+
func HierValues( h *Hierarchy ) map[string]interface{} {
|
| 336 |
+
r := make(map[string]interface{})
|
| 337 |
+
for name,each := range h.Signals {
|
| 338 |
+
r[name] = each.Value
|
| 339 |
+
}
|
| 340 |
+
for name,each := range h.Nested {
|
| 341 |
+
r[name] = HierValues(each)
|
| 342 |
+
}
|
| 343 |
+
return r
|
| 344 |
+
}
|
| 345 |
+
|
| 346 |
+
func replaceHex( s string ) string {
|
| 347 |
+
re := regexp.MustCompile("\\$[a-fA-F0-9]+")
|
| 348 |
+
matches := re.FindAllString( s, -1 )
|
| 349 |
+
for _, each := range matches {
|
| 350 |
+
v, _ := strconv.ParseUint( each[1:], 16, 64 )
|
| 351 |
+
s = strings.ReplaceAll( s, each, fmt.Sprintf("%d",v) )
|
| 352 |
+
}
|
| 353 |
+
return s
|
| 354 |
+
}
|
| 355 |
+
|
| 356 |
+
func setSignal( s string, hier *Hierarchy ) {
|
| 357 |
+
tokens := strings.Split(s,"=")
|
| 358 |
+
if len(tokens)!=2 {
|
| 359 |
+
fmt.Println("Wrong expression ", s)
|
| 360 |
+
return
|
| 361 |
+
}
|
| 362 |
+
p := findSignal(tokens[0], hier )
|
| 363 |
+
if p==nil {
|
| 364 |
+
fmt.Println(s, " not found")
|
| 365 |
+
return
|
| 366 |
+
}
|
| 367 |
+
if tokens[1]!="" && tokens[1][0]=='$' { // ignore a $ before the number
|
| 368 |
+
tokens[1]=tokens[1][1:]
|
| 369 |
+
}
|
| 370 |
+
p.Value, _ = strconv.ParseUint( tokens[1],16, 64)
|
| 371 |
+
}
|
| 372 |
+
|
| 373 |
+
func findSignal( s string, h *Hierarchy ) *VCDSignal {
|
| 374 |
+
t := strings.Split(s,".")
|
| 375 |
+
k:=0
|
| 376 |
+
for ; k<len(t)-1;k++ {
|
| 377 |
+
nx, f := h.Nested[t[k]]
|
| 378 |
+
if !f {
|
| 379 |
+
return nil
|
| 380 |
+
}
|
| 381 |
+
h = nx
|
| 382 |
+
}
|
| 383 |
+
signal, f := h.Signals[t[k]]
|
| 384 |
+
if !f {
|
| 385 |
+
return nil
|
| 386 |
+
}
|
| 387 |
+
return signal
|
| 388 |
+
}
|
| 389 |
+
|
| 390 |
+
func ( this *NameValue ) showDiff( o NameValue ) bool {
|
| 391 |
+
if o==nil || len(o)==0 || len(*this)==0 { return true }
|
| 392 |
+
cnt:=0
|
| 393 |
+
diff := false
|
| 394 |
+
for k,v := range *this {
|
| 395 |
+
v2, f := o[k]
|
| 396 |
+
if f && v!=v2 {
|
| 397 |
+
if k=="frame_cnt" {
|
| 398 |
+
fmt.Printf("%s='d%d\t",k,v)
|
| 399 |
+
} else {
|
| 400 |
+
fmt.Printf("%s=%x\t",k,v)
|
| 401 |
+
}
|
| 402 |
+
cnt++
|
| 403 |
+
if cnt==8 {
|
| 404 |
+
cnt=0
|
| 405 |
+
fmt.Print("\n")
|
| 406 |
+
}
|
| 407 |
+
diff = true
|
| 408 |
+
}
|
| 409 |
+
}
|
| 410 |
+
if cnt!=0 { fmt.Printf("\n") }
|
| 411 |
+
return diff
|
| 412 |
+
}
|
| 413 |
+
|
| 414 |
+
func (file *LnFile) NextVCD( ss VCDData ) bool {
|
| 415 |
+
// fmt.Printf("%s (#%d @%d):\n",file.fname,file.time, file.line)
|
| 416 |
+
for file.Scan() {
|
| 417 |
+
txt := file.Text()
|
| 418 |
+
if txt[0]=='#' {
|
| 419 |
+
file.time, _ = strconv.ParseUint( txt[1:],10,64 )
|
| 420 |
+
return true
|
| 421 |
+
}
|
| 422 |
+
// fmt.Printf("\t%s\n",txt)
|
| 423 |
+
a, v := parseValue(txt)
|
| 424 |
+
assign( a, v, ss )
|
| 425 |
+
}
|
| 426 |
+
return false // EOF
|
| 427 |
+
}
|
| 428 |
+
|
| 429 |
+
// advance the VCD scan upto the next change in any of the provided signals
|
| 430 |
+
func (file *LnFile) NextChangeIn( ss VCDData, names []string ) bool {
|
| 431 |
+
// fmt.Printf("%s (#%d @%d):\n",file.fname,file.time, file.line)
|
| 432 |
+
found := false
|
| 433 |
+
for file.Scan() {
|
| 434 |
+
txt := file.Text()
|
| 435 |
+
if txt[0]=='#' {
|
| 436 |
+
file.time, _ = strconv.ParseUint( txt[1:],10,64 )
|
| 437 |
+
if found {
|
| 438 |
+
return true
|
| 439 |
+
} else {
|
| 440 |
+
continue
|
| 441 |
+
}
|
| 442 |
+
}
|
| 443 |
+
// fmt.Printf("\t%s\n",txt)
|
| 444 |
+
a, v := parseValue(txt)
|
| 445 |
+
if slices.Contains( names, a ) { found = true }
|
| 446 |
+
assign( a, v, ss )
|
| 447 |
+
}
|
| 448 |
+
return false // EOF
|
| 449 |
+
}
|
| 450 |
+
|
| 451 |
+
// advance until given time
|
| 452 |
+
func (file *LnFile) MoveTo( ss VCDData, t0 uint64 ) bool {
|
| 453 |
+
good := true
|
| 454 |
+
for file.time<t0 && good { good = file.NextVCD(ss) }
|
| 455 |
+
return good
|
| 456 |
+
}
|
| 457 |
+
|
| 458 |
+
func GetSignals( file *LnFile ) VCDData {
|
| 459 |
+
ss := make(VCDData)
|
| 460 |
+
scope := ""
|
| 461 |
+
type Mode int
|
| 462 |
+
const(
|
| 463 |
+
SCAN Mode = iota
|
| 464 |
+
PASS
|
| 465 |
+
INIT
|
| 466 |
+
)
|
| 467 |
+
mode := SCAN
|
| 468 |
+
scan_through:
|
| 469 |
+
for ; file.scn.Scan(); file.line++ {
|
| 470 |
+
txt := file.scn.Text()
|
| 471 |
+
switch(mode) {
|
| 472 |
+
case SCAN: {
|
| 473 |
+
tokens := strings.Fields(txt)
|
| 474 |
+
switch(tokens[0]) {
|
| 475 |
+
case "$date","$version","$timescale": mode=PASS
|
| 476 |
+
case "$scope": {
|
| 477 |
+
if tokens[1]!="module" {
|
| 478 |
+
fmt.Printf("Unknown syntax at line %d: %s\n",file.line, txt)
|
| 479 |
+
}
|
| 480 |
+
if scope!="" { scope += "." }
|
| 481 |
+
scope += tokens[2]
|
| 482 |
+
}
|
| 483 |
+
case "$upscope": {
|
| 484 |
+
if i := strings.LastIndex(scope,"."); i!=-1 {
|
| 485 |
+
scope = scope[0:i]
|
| 486 |
+
}
|
| 487 |
+
}
|
| 488 |
+
case "$var": {
|
| 489 |
+
if tokens[1]!="wire" {
|
| 490 |
+
fmt.Printf("Unknown syntax at line %d: %s\n",file.line, txt)
|
| 491 |
+
break
|
| 492 |
+
}
|
| 493 |
+
s := &VCDSignal{
|
| 494 |
+
Scope: scope,
|
| 495 |
+
alias: tokens[3],
|
| 496 |
+
}
|
| 497 |
+
bracket_str := tokens[4]
|
| 498 |
+
bracket := 0
|
| 499 |
+
if tokens[5][0]=='[' { // bus expression is separated
|
| 500 |
+
bracket_str = tokens[5]
|
| 501 |
+
s.Name = tokens[4]
|
| 502 |
+
} else {
|
| 503 |
+
bracket = strings.Index(tokens[4],"[")
|
| 504 |
+
if bracket == -1 {
|
| 505 |
+
s.Name = tokens[4]
|
| 506 |
+
bracket_str = ""
|
| 507 |
+
} else {
|
| 508 |
+
s.Name = tokens[4][0:bracket]
|
| 509 |
+
bracket_str = tokens[4]
|
| 510 |
+
bracket++
|
| 511 |
+
}
|
| 512 |
+
}
|
| 513 |
+
if bracket_str!="" {
|
| 514 |
+
bend := strings.Index(bracket_str,"]")
|
| 515 |
+
parts := strings.Split(bracket_str[bracket:bend-1],":")
|
| 516 |
+
s.MSB,_ = strconv.Atoi(parts[0])
|
| 517 |
+
if len(parts)==2 {
|
| 518 |
+
s.LSB,_ = strconv.Atoi(parts[1])
|
| 519 |
+
}
|
| 520 |
+
}
|
| 521 |
+
ss[s.alias] = s
|
| 522 |
+
}
|
| 523 |
+
case "$dumpvars": mode = INIT
|
| 524 |
+
}
|
| 525 |
+
}
|
| 526 |
+
case INIT: {
|
| 527 |
+
if txt=="$end" {
|
| 528 |
+
file.line++
|
| 529 |
+
break scan_through
|
| 530 |
+
}
|
| 531 |
+
a, v := parseValue( txt )
|
| 532 |
+
assign( a, v, ss )
|
| 533 |
+
}
|
| 534 |
+
case PASS : {
|
| 535 |
+
if txt=="$end" {
|
| 536 |
+
mode = SCAN
|
| 537 |
+
}
|
| 538 |
+
}
|
| 539 |
+
}
|
| 540 |
+
}
|
| 541 |
+
return ss
|
| 542 |
+
}
|
| 543 |
+
|
| 544 |
+
|
| 545 |
+
func assign( alias string, v uint64, ss VCDData) {
|
| 546 |
+
p, _ := ss[alias]
|
| 547 |
+
if p==nil {
|
| 548 |
+
if alias=="" || alias==" " {
|
| 549 |
+
fmt.Println("vcd_parser: called assign with no signal alias")
|
| 550 |
+
os.Exit(1)
|
| 551 |
+
}
|
| 552 |
+
fmt.Printf("Warning: signal VCDData aliased as -> %s <- not found\n",alias)
|
| 553 |
+
return
|
| 554 |
+
}
|
| 555 |
+
p.Value = v
|
| 556 |
+
}
|
| 557 |
+
|
| 558 |
+
func parseValue( txt string ) ( string, uint64 ) {
|
| 559 |
+
if txt[0]!='0' && txt[0]!='1' && txt[0]!='b' {
|
| 560 |
+
fmt.Printf("Warning: unexpected value definition %s\n",txt)
|
| 561 |
+
return "",0
|
| 562 |
+
}
|
| 563 |
+
var v uint64
|
| 564 |
+
if txt[0] == 'b' {
|
| 565 |
+
var s int
|
| 566 |
+
for s=1; s<len(txt) && txt[s]!=' '; s++ {
|
| 567 |
+
v <<= 1
|
| 568 |
+
if txt[s]=='1' {
|
| 569 |
+
v |= 1
|
| 570 |
+
}
|
| 571 |
+
}
|
| 572 |
+
s++
|
| 573 |
+
return txt[s:], v
|
| 574 |
+
} else {
|
| 575 |
+
if txt[0]=='1' { v=1 }
|
| 576 |
+
return txt[1:], v
|
| 577 |
+
}
|
| 578 |
+
}
|
snapshots/jotego_jtcores_pr1270/modules/jtframe/syn/cpu/pauloblaze.qip
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
set_global_assignment -name VHDL_FILE [file join $::quartus(qip_path) ../../hdl/cpu/pauloblaze/op_codes.vhd ]
|
| 2 |
+
set_global_assignment -name VHDL_FILE [file join $::quartus(qip_path) ../../hdl/cpu/pauloblaze/alu.vhd ]
|
| 3 |
+
set_global_assignment -name VHDL_FILE [file join $::quartus(qip_path) ../../hdl/cpu/pauloblaze/decoder.vhd ]
|
| 4 |
+
set_global_assignment -name VHDL_FILE [file join $::quartus(qip_path) ../../hdl/cpu/pauloblaze/io_module.vhd ]
|
| 5 |
+
set_global_assignment -name VHDL_FILE [file join $::quartus(qip_path) ../../hdl/cpu/pauloblaze/pauloBlaze.vhd ]
|
| 6 |
+
set_global_assignment -name VHDL_FILE [file join $::quartus(qip_path) ../../hdl/cpu/pauloblaze/program_counter.vhd ]
|
| 7 |
+
set_global_assignment -name VHDL_FILE [file join $::quartus(qip_path) ../../hdl/cpu/pauloblaze/regFile.vhd ]
|
snapshots/jotego_jtcores_pr1270/modules/jtframe/syn/jtframe_2308/adc_test.sdc
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
|
|
|
| 1 |
+
create_clock -period "50.0 MHz" [get_ports FPGA_CLK1_50]
|
| 2 |
+
|
snapshots/jotego_jtcores_pr1270/modules/jtframe/syn/jtframe_2308/adc_test.v
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
module adc_test(
|
| 2 |
+
input FPGA_CLK1_50,
|
| 3 |
+
output LED_USER,
|
| 4 |
+
output LED_HDD,
|
| 5 |
+
output LED_POWER,
|
| 6 |
+
output [7:0] LED,
|
| 7 |
+
// ADC
|
| 8 |
+
output ADC_CONVST,
|
| 9 |
+
output ADC_SCK,
|
| 10 |
+
output ADC_SDI,
|
| 11 |
+
input ADC_SDO
|
| 12 |
+
);
|
| 13 |
+
|
| 14 |
+
wire clk = FPGA_CLK1_50;
|
| 15 |
+
reg [7:0] ledsr = 8'd1;
|
| 16 |
+
|
| 17 |
+
reg [25:0] cnt=0;
|
| 18 |
+
wire [2:0] LEDmister;
|
| 19 |
+
// assign LED = ledsr;
|
| 20 |
+
assign {LED_POWER,LED_HDD,LED_USER} = LEDmister; //~{ |ledsr[7:6], |ledsr[5:3], |ledsr[2:0] };
|
| 21 |
+
|
| 22 |
+
always @(posedge clk) begin
|
| 23 |
+
if( cnt[25] ) begin
|
| 24 |
+
cnt <= 0;
|
| 25 |
+
ledsr <= { ledsr[6:0], ledsr[7] };
|
| 26 |
+
end else begin
|
| 27 |
+
cnt <= cnt + 26'd1;
|
| 28 |
+
end
|
| 29 |
+
end
|
| 30 |
+
|
| 31 |
+
reg [5:0] rst_sr=6'b100_000;
|
| 32 |
+
always @(negedge clk) begin
|
| 33 |
+
rst_sr <= { rst_sr[4:0], 1'b1 };
|
| 34 |
+
end
|
| 35 |
+
|
| 36 |
+
wire rst_n = rst_sr[5];
|
| 37 |
+
|
| 38 |
+
reg [1:0] cen_cnt=0;
|
| 39 |
+
reg cen;
|
| 40 |
+
always @(negedge clk) begin
|
| 41 |
+
cen_cnt <= cen_cnt+2'd1;
|
| 42 |
+
cen <= cen_cnt == 2'b00;
|
| 43 |
+
end
|
| 44 |
+
|
| 45 |
+
wire [11:0] adc_read;
|
| 46 |
+
assign { LEDmister, LED } = {~adc_read[10:8], adc_read[7:0]};
|
| 47 |
+
|
| 48 |
+
/*
|
| 49 |
+
always @(*) begin
|
| 50 |
+
if( adc_read < 12'd64 ) LEDmister <= 3'b000;
|
| 51 |
+
else
|
| 52 |
+
if( adc_read < 12'd512 ) LEDmister <= 3'b001;
|
| 53 |
+
else
|
| 54 |
+
if( adc_read < 12'd1512 ) LEDmister <= 3'b011;
|
| 55 |
+
else LEDmister <= 3'b111;
|
| 56 |
+
end
|
| 57 |
+
*/
|
| 58 |
+
jtframe_2308 adc(
|
| 59 |
+
.rst_n ( rst_n ),
|
| 60 |
+
.clk ( clk ),
|
| 61 |
+
.cen ( cen ), // CEN+CLK < 40MHz
|
| 62 |
+
// ADC control
|
| 63 |
+
.adc_sdo ( ADC_SDO ),
|
| 64 |
+
.adc_convst ( ADC_CONVST ),
|
| 65 |
+
.adc_sck ( ADC_SCK ),
|
| 66 |
+
.adc_sdi ( ADC_SDI ),
|
| 67 |
+
// ADC read data
|
| 68 |
+
.adc_read ( adc_read )
|
| 69 |
+
);
|
| 70 |
+
|
| 71 |
+
|
| 72 |
+
endmodule
|
snapshots/jotego_jtcores_pr1270/modules/jtframe/syn/jtframe_2308/makefile
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
PROJECT=adc_test
|
| 2 |
+
SOURCE_FILES= \
|
| 3 |
+
../../hdl/mister/jtframe_2308.v \
|
| 4 |
+
adc_test.v set_pins.tcl
|
| 5 |
+
|
| 6 |
+
ASSIGNMENT_FILES = adc_test.qpf adc_test.qsf
|
| 7 |
+
|
| 8 |
+
all: smart.log $(PROJECT).asm.rpt $(PROJECT).sta.rpt
|
| 9 |
+
|
| 10 |
+
clean:
|
| 11 |
+
rm -rf *.rpt *.chg smart.log *.htm *.eqn *.pin *.sof *.pof db qdb
|
| 12 |
+
rm -rf hc_output incremental_db *jdi *fit.* *summary
|
| 13 |
+
rm -f $(PROJECT).qsf *.qws *.qpf *.smsg
|
| 14 |
+
|
| 15 |
+
prog: $(PROJECT).sof
|
| 16 |
+
quartus_pgm -c "DE-SoC [1-1.2.1.1]" $(PROJECT).sof
|
| 17 |
+
|
| 18 |
+
map: smart.log $(PROJECT).map.rpt
|
| 19 |
+
fit: smart.log $(PROJECT).fit.rpt
|
| 20 |
+
asm: smart.log $(PROJECT).asm.rpt
|
| 21 |
+
sta: smart.log $(PROJECT).sta.rpt
|
| 22 |
+
smart: smart.log
|
| 23 |
+
|
| 24 |
+
MAP_ARGS = --family="Cyclone V"
|
| 25 |
+
# MAP_ARGS = --part=5CSEBA6U23I7DK
|
| 26 |
+
FIT_ARGS = --part=5CSEBA6U23I7
|
| 27 |
+
ASM_ARGS =
|
| 28 |
+
STA_ARGS =
|
| 29 |
+
|
| 30 |
+
STAMP = echo done >
|
| 31 |
+
|
| 32 |
+
$(PROJECT).map.rpt: map.chg $(SOURCE_FILES)
|
| 33 |
+
quartus_map $(MAP_ARGS) $(PROJECT)
|
| 34 |
+
$(STAMP) asm.chg
|
| 35 |
+
$(STAMP) sta.chg
|
| 36 |
+
|
| 37 |
+
$(PROJECT).fit.rpt: fit.chg $(PROJECT).map.rpt
|
| 38 |
+
quartus_fit $(FIT_ARGS) $(PROJECT)
|
| 39 |
+
$(STAMP) asm.chg
|
| 40 |
+
# $(STAMP) sta.chg
|
| 41 |
+
|
| 42 |
+
$(PROJECT).asm.rpt: asm.chg $(PROJECT).fit.rpt
|
| 43 |
+
quartus_asm $(ASM_ARGS) $(PROJECT)
|
| 44 |
+
|
| 45 |
+
$(PROJECT).sta.rpt: sta.chg $(PROJECT).fit.rpt
|
| 46 |
+
quartus_sta $(STA_ARGS) $(PROJECT)
|
| 47 |
+
|
| 48 |
+
smart.log: $(ASSIGNMENT_FILES)
|
| 49 |
+
quartus_sh --determine_smart_action $(PROJECT) > smart.log
|
| 50 |
+
|
| 51 |
+
$(ASSIGNMENT_FILES): set_pins.tcl
|
| 52 |
+
quartus_sh --prepare $(PROJECT)
|
| 53 |
+
quartus_sh -t set_pins.tcl
|
| 54 |
+
|
| 55 |
+
map.chg:
|
| 56 |
+
$(STAMP) map.chg
|
| 57 |
+
fit.chg:
|
| 58 |
+
$(STAMP) fit.chg
|
| 59 |
+
sta.chg:
|
| 60 |
+
$(STAMP) sta.chg
|
| 61 |
+
asm.chg:
|
| 62 |
+
$(STAMP) asm.chg
|
| 63 |
+
|
snapshots/jotego_jtcores_pr1270/modules/jtframe/syn/jtframe_2308/set_pins.tcl
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
project_open adc_test
|
| 2 |
+
|
| 3 |
+
# Files
|
| 4 |
+
set_global_assignment -name QIP_FILE source.qip
|
| 5 |
+
|
| 6 |
+
# Pins
|
| 7 |
+
set_instance_assignment -name IO_STANDARD "3.3-V LVTTL" -to LED[0]
|
| 8 |
+
set_instance_assignment -name IO_STANDARD "3.3-V LVTTL" -to LED[1]
|
| 9 |
+
set_instance_assignment -name IO_STANDARD "3.3-V LVTTL" -to LED[2]
|
| 10 |
+
set_instance_assignment -name IO_STANDARD "3.3-V LVTTL" -to LED[3]
|
| 11 |
+
set_instance_assignment -name IO_STANDARD "3.3-V LVTTL" -to LED[4]
|
| 12 |
+
set_instance_assignment -name IO_STANDARD "3.3-V LVTTL" -to LED[5]
|
| 13 |
+
set_instance_assignment -name IO_STANDARD "3.3-V LVTTL" -to LED[6]
|
| 14 |
+
set_instance_assignment -name IO_STANDARD "3.3-V LVTTL" -to LED[7]
|
| 15 |
+
set_location_assignment PIN_W15 -to LED[0]
|
| 16 |
+
set_location_assignment PIN_AA24 -to LED[1]
|
| 17 |
+
set_location_assignment PIN_V16 -to LED[2]
|
| 18 |
+
set_location_assignment PIN_V15 -to LED[3]
|
| 19 |
+
set_location_assignment PIN_AF26 -to LED[4]
|
| 20 |
+
set_location_assignment PIN_AE26 -to LED[5]
|
| 21 |
+
set_location_assignment PIN_Y16 -to LED[6]
|
| 22 |
+
set_location_assignment PIN_AA23 -to LED[7]
|
| 23 |
+
|
| 24 |
+
#============================================================
|
| 25 |
+
# I/O
|
| 26 |
+
#============================================================
|
| 27 |
+
set_location_assignment PIN_Y15 -to LED_USER
|
| 28 |
+
set_location_assignment PIN_AA15 -to LED_HDD
|
| 29 |
+
set_location_assignment PIN_AG28 -to LED_POWER
|
| 30 |
+
|
| 31 |
+
#set_location_assignment PIN_AH24 -to BTN_USER
|
| 32 |
+
#set_location_assignment PIN_AG25 -to BTN_OSD
|
| 33 |
+
#set_location_assignment PIN_AG23 -to BTN_RESET
|
| 34 |
+
|
| 35 |
+
set_instance_assignment -name IO_STANDARD "3.3-V LVTTL" -to LED_*
|
| 36 |
+
#set_instance_assignment -name IO_STANDARD "3.3-V LVTTL" -to BTN_*
|
| 37 |
+
#set_instance_assignment -name WEAK_PULL_UP_RESISTOR ON -to BTN_*
|
| 38 |
+
|
| 39 |
+
|
| 40 |
+
set_instance_assignment -name IO_STANDARD "3.3-V LVTTL" -to FPGA_CLK1_50
|
| 41 |
+
set_location_assignment PIN_V11 -to FPGA_CLK1_50
|
| 42 |
+
set_global_assignment -name POWER_PRESET_COOLING_SOLUTION "23 MM HEAT SINK WITH 200 LFPM AIRFLOW"
|
| 43 |
+
set_global_assignment -name POWER_BOARD_THERMAL_MODEL "NONE (CONSERVATIVE)"
|
| 44 |
+
|
| 45 |
+
|
| 46 |
+
#============================================================
|
| 47 |
+
# ADC
|
| 48 |
+
#============================================================
|
| 49 |
+
set_instance_assignment -name IO_STANDARD "3.3-V LVTTL" -to ADC_CONVST
|
| 50 |
+
set_instance_assignment -name IO_STANDARD "3.3-V LVTTL" -to ADC_SCK
|
| 51 |
+
set_instance_assignment -name IO_STANDARD "3.3-V LVTTL" -to ADC_SDI
|
| 52 |
+
set_instance_assignment -name IO_STANDARD "3.3-V LVTTL" -to ADC_SDO
|
| 53 |
+
set_location_assignment PIN_U9 -to ADC_CONVST
|
| 54 |
+
set_location_assignment PIN_V10 -to ADC_SCK
|
| 55 |
+
set_location_assignment PIN_AC4 -to ADC_SDI
|
| 56 |
+
set_location_assignment PIN_AD4 -to ADC_SDO
|
| 57 |
+
set_instance_assignment -name PARTITION_HIERARCHY root_partition -to | -section_id Top
|
snapshots/jotego_jtcores_pr1270/modules/jtframe/syn/jtframe_2308/source.qip
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
set_global_assignment -name VERILOG_FILE [file join $::quartus(qip_path) ../../hdl/mister/jtframe_2308.v ]
|
| 2 |
+
set_global_assignment -name VERILOG_FILE [file join $::quartus(qip_path) adc_test.v ]
|
| 3 |
+
set_global_assignment -name SDC_FILE [file join $::quartus(qip_path) adc_test.sdc ]
|
snapshots/jotego_jtcores_pr1270/modules/jtframe/target/mist/cfg/common.yaml
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Common files to MiST, SiDi and NeptUNO
|
| 2 |
+
jtframe:
|
| 3 |
+
- from: sound
|
| 4 |
+
unless: [ POCKET ]
|
| 5 |
+
get:
|
| 6 |
+
- hybrid_pwm_sd.v
|
| 7 |
+
- hifi_1bit_dac.v
|
| 8 |
+
- from: clocking
|
| 9 |
+
get:
|
| 10 |
+
- jtframe_sync.v
|
| 11 |
+
- jtframe_rst_sync.v
|
| 12 |
+
# JTFRAME scan doubler for memory constrained systems
|
| 13 |
+
- from: video
|
| 14 |
+
get:
|
| 15 |
+
- jtframe_scan2x.v
|
| 16 |
+
- from: video/rotate
|
| 17 |
+
get:
|
| 18 |
+
- scandoubler_rgb_interp.v
|
| 19 |
+
- scandoubler_rotate.v
|
| 20 |
+
- scandoubler_scaledepth.v
|
| 21 |
+
- scandoubler_sdram.v
|
| 22 |
+
- unsigned_division.v
|
| 23 |
+
- pixel_interp.v
|
| 24 |
+
- frac_interp.v
|
| 25 |
+
jtframe/target/mist:
|
| 26 |
+
- get:
|
| 27 |
+
- jtframe_mist_clocks.v
|
| 28 |
+
- jtframe_mist_video.v
|
| 29 |
+
- osd.sv
|
| 30 |
+
- rgb2ypbpr.v
|
| 31 |
+
- unless: [ SIDI128, POCKET ]
|
| 32 |
+
get:
|
| 33 |
+
- pll_game.qip
|
| 34 |
+
- unless: [ POCKET ]
|
| 35 |
+
get:
|
| 36 |
+
- jtframe_mist_base.v
|
| 37 |
+
- mist_io.sdc
|
| 38 |
+
- unless: [ SIDI128, POCKET ]
|
| 39 |
+
get:
|
| 40 |
+
- sdram_clk.sdc # must come after mist_io.sdc
|
| 41 |
+
# PLLs
|
| 42 |
+
- unless: [ SIDI128 ]
|
| 43 |
+
get:
|
| 44 |
+
- pll.qip
|
| 45 |
+
jtframe/target/mister:
|
| 46 |
+
- unless: [ VERILATOR ]
|
| 47 |
+
from: sys
|
| 48 |
+
get:
|
| 49 |
+
- yc_out.sv
|
snapshots/jotego_jtcores_pr1270/modules/jtframe/target/mist/cfg/files.yaml
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
jtframe/target/mist:
|
| 2 |
+
- get:
|
| 3 |
+
- common.yaml
|
| 4 |
+
- jtframe_mist_top.sv
|
| 5 |
+
- jtframe_mist.sv
|
| 6 |
+
- jtframe_mist_video.v
|
| 7 |
+
- user_io.v
|
| 8 |
+
- i2c_master.v
|
| 9 |
+
- i2s.v
|
| 10 |
+
- spdif.v
|
| 11 |
+
- data_io.v
|
snapshots/jotego_jtcores_pr1270/modules/jtframe/target/mist/cfg/sim.yaml
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
jtframe:
|
| 2 |
+
- from: clocking
|
| 3 |
+
get:
|
| 4 |
+
- jtframe_rst_sync.v
|
| 5 |
+
- jtframe_sync.v
|
| 6 |
+
- from: ver
|
| 7 |
+
get:
|
| 8 |
+
- video_dump.v
|
| 9 |
+
- mt48lc16m16a2.v
|
| 10 |
+
- spitx.v
|
| 11 |
+
- fast_pll.v
|
| 12 |
+
- jtframe_romrq_rdy_check.v
|
| 13 |
+
jtframe/target/mist:
|
| 14 |
+
- unless: [ VERILATOR ]
|
| 15 |
+
from: ../ver
|
| 16 |
+
get:
|
| 17 |
+
- mist_test.v
|
| 18 |
+
- test_harness.v
|
snapshots/jotego_jtcores_pr1270/modules/jtframe/target/mist/cfgstr
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{{.CORENAME}};;
|
| 2 |
+
|
| 3 |
+
DIP;
|
| 4 |
+
{{ if .JTFRAME_OSD_LOAD }} F,rom; {{ end }}
|
| 5 |
+
{{ if .JTFRAME_VERTICAL }}
|
| 6 |
+
{{ if .JTFRAME_OSD_FLIP }} O1,Flip screen,Off,On; {{ end }}
|
| 7 |
+
O2,Rotate controls,Yes,No;
|
| 8 |
+
{{ if .JTFRAME_SDRAM_ROTATION }} OD,Screen Rotation,No,Yes; {{ end }}{{ end }}
|
| 9 |
+
O34,Video Mode, pass thru, linear, analogue, dark;
|
| 10 |
+
{{ if .JTFRAME_JOY1_POS }} OIJ,Player 1 character,First,Second,Third,Fourth; {{ end }}
|
| 11 |
+
{{ if .JTFRAME_OSD_VOL }} O67,FX volume, high, very high, very low, low; {{ end }}
|
| 12 |
+
{{ if .JTFRAME_OSD_TEST }} OA,Test mode,Off,On; {{ end }}
|
| 13 |
+
{{ if .JTFRAME_DIAL }} O67,Sensitivity,high,highest,lowest,low;{{end}}
|
| 14 |
+
{{ if not .JTFRAME_OSD_NOCREDITS }} OC,Pause,Off,On; {{ end }}
|
| 15 |
+
{{ .SEPARATOR }}
|
| 16 |
+
{{ .CORE_OSD }}
|
| 17 |
+
{{ with .JTFRAME_IOCTL_RD }} R{{ . }},Save NVRAM;{{ end }}
|
| 18 |
+
T0,Reset v{{.JTFRAME_COMMIT}};
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
//
|
| 2 |
+
// data_io.v
|
| 3 |
+
//
|
| 4 |
+
// data_io for the MiST board
|
| 5 |
+
// https://github.com/mist-devel
|
| 6 |
+
//
|
| 7 |
+
// Copyright (c) 2014 Till Harbaum <till@harbaum.org>
|
| 8 |
+
//
|
| 9 |
+
// This source file is free software: you can redistribute it and/or modify
|
| 10 |
+
// it under the terms of the GNU General Public License as published
|
| 11 |
+
// by the Free Software Foundation, either version 3 of the License, or
|
| 12 |
+
// (at your option) any later version.
|
| 13 |
+
//
|
| 14 |
+
// This source file is distributed in the hope that it will be useful,
|
| 15 |
+
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
| 16 |
+
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
| 17 |
+
// GNU General Public License for more details.
|
| 18 |
+
//
|
| 19 |
+
// You should have received a copy of the GNU General Public License
|
| 20 |
+
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
| 21 |
+
//
|
| 22 |
+
///////////////////////////////////////////////////////////////////////
|
| 23 |
+
|
| 24 |
+
module data_io #( parameter
|
| 25 |
+
START_ADDR = 27'd0,
|
| 26 |
+
ROM_DIRECT_UPLOAD = 1'b0,
|
| 27 |
+
USE_QSPI = 1'b0,
|
| 28 |
+
ENABLE_IDE = 1'b0,
|
| 29 |
+
DOUT_16 = 1'b0
|
| 30 |
+
)(
|
| 31 |
+
input clk_sys,
|
| 32 |
+
input SPI_SCK,
|
| 33 |
+
input SPI_SS2,
|
| 34 |
+
input SPI_SS4,
|
| 35 |
+
input SPI_DI,
|
| 36 |
+
inout SPI_DO,
|
| 37 |
+
|
| 38 |
+
input QCSn,
|
| 39 |
+
input QSCK,
|
| 40 |
+
input [3:0] QDAT,
|
| 41 |
+
|
| 42 |
+
input clkref_n, // assert ioctl_wr one cycle after clkref stobe (negative active)
|
| 43 |
+
|
| 44 |
+
// ARM -> FPGA download
|
| 45 |
+
output reg ioctl_download = 0, // signal indicating an active download
|
| 46 |
+
output reg ioctl_upload = 0, // signal indicating an active upload
|
| 47 |
+
output reg [7:0] ioctl_index, // menu index used to upload the file ([7:6] - extension index, [5:0] - menu index)
|
| 48 |
+
// Note: this is also set for user_io mounts.
|
| 49 |
+
// Valid when ioctl_download = 1 or when img_mounted strobe is active in user_io.
|
| 50 |
+
output reg ioctl_wr, // strobe indicating ioctl_dout valid
|
| 51 |
+
output reg [26:0] ioctl_addr,
|
| 52 |
+
output reg [((DOUT_16+1)*8)-1:0] ioctl_dout,
|
| 53 |
+
input [7:0] ioctl_din,
|
| 54 |
+
output reg [23:0] ioctl_fileext, // file extension
|
| 55 |
+
output reg [31:0] ioctl_filesize, // file size
|
| 56 |
+
|
| 57 |
+
// IDE interface
|
| 58 |
+
input hdd_clk,
|
| 59 |
+
input hdd_cmd_req,
|
| 60 |
+
input hdd_cdda_req,
|
| 61 |
+
input hdd_dat_req,
|
| 62 |
+
output hdd_cdda_wr,
|
| 63 |
+
output hdd_status_wr,
|
| 64 |
+
output [2:0] hdd_addr,
|
| 65 |
+
output hdd_wr,
|
| 66 |
+
|
| 67 |
+
output [15:0] hdd_data_out,
|
| 68 |
+
input [15:0] hdd_data_in,
|
| 69 |
+
output hdd_data_rd,
|
| 70 |
+
output hdd_data_wr,
|
| 71 |
+
|
| 72 |
+
// IDE config
|
| 73 |
+
output [1:0] hdd0_ena,
|
| 74 |
+
output [1:0] hdd1_ena
|
| 75 |
+
);
|
| 76 |
+
|
| 77 |
+
`ifdef SIMULATION
|
| 78 |
+
initial begin
|
| 79 |
+
ioctl_index = 8'h1;
|
| 80 |
+
end
|
| 81 |
+
`endif
|
| 82 |
+
|
| 83 |
+
/////////////////////////////// DOWNLOADING ///////////////////////////////
|
| 84 |
+
|
| 85 |
+
reg [6:0] sbuf;
|
| 86 |
+
reg [7:0] data_w;
|
| 87 |
+
reg [7:0] data_w2 = 0;
|
| 88 |
+
reg [15:0] data_w3 = 0;
|
| 89 |
+
reg [3:0] cnt;
|
| 90 |
+
reg [7:0] cmd;
|
| 91 |
+
reg [6:0] bytecnt;
|
| 92 |
+
|
| 93 |
+
reg rclk = 0;
|
| 94 |
+
reg rclk2 = 0;
|
| 95 |
+
reg rclk3 = 0;
|
| 96 |
+
reg addr_reset = 0;
|
| 97 |
+
reg downloading_reg = 0;
|
| 98 |
+
reg uploading_reg = 0;
|
| 99 |
+
reg reg_do;
|
| 100 |
+
|
| 101 |
+
localparam DIO_FILE_TX = 8'h53;
|
| 102 |
+
localparam DIO_FILE_TX_DAT = 8'h54;
|
| 103 |
+
localparam DIO_FILE_INDEX = 8'h55;
|
| 104 |
+
localparam DIO_FILE_INFO = 8'h56;
|
| 105 |
+
localparam DIO_FILE_RX = 8'h57;
|
| 106 |
+
localparam DIO_FILE_RX_DAT = 8'h58;
|
| 107 |
+
|
| 108 |
+
localparam QSPI_READ = 8'h40;
|
| 109 |
+
localparam QSPI_WRITE = 8'h41;
|
| 110 |
+
|
| 111 |
+
localparam CMD_IDE_REGS_RD = 8'h80;
|
| 112 |
+
localparam CMD_IDE_REGS_WR = 8'h90;
|
| 113 |
+
localparam CMD_IDE_DATA_WR = 8'hA0;
|
| 114 |
+
localparam CMD_IDE_DATA_RD = 8'hB0;
|
| 115 |
+
localparam CMD_IDE_CDDA_RD = 8'hC0;
|
| 116 |
+
localparam CMD_IDE_CDDA_WR = 8'hD0;
|
| 117 |
+
localparam CMD_IDE_STATUS_WR = 8'hF0;
|
| 118 |
+
localparam CMD_IDE_CFG_WR = 8'hFA;
|
| 119 |
+
|
| 120 |
+
assign SPI_DO = reg_do;
|
| 121 |
+
|
| 122 |
+
// data_io has its own SPI interface to the io controller
|
| 123 |
+
wire [7:0] cmdcode = { 4'h0, hdd_dat_req, hdd_cmd_req, 2'b00 };
|
| 124 |
+
|
| 125 |
+
always@(negedge SPI_SCK or posedge SPI_SS2) begin : SPI_TRANSMITTER
|
| 126 |
+
reg [7:0] dout_r;
|
| 127 |
+
reg oe;
|
| 128 |
+
|
| 129 |
+
if(SPI_SS2) begin
|
| 130 |
+
oe <= 0;
|
| 131 |
+
reg_do <= 1'bZ;
|
| 132 |
+
end else begin
|
| 133 |
+
if (cnt == 15) begin
|
| 134 |
+
oe <= 1;
|
| 135 |
+
case(cmd)
|
| 136 |
+
CMD_IDE_REGS_RD,
|
| 137 |
+
CMD_IDE_DATA_RD:
|
| 138 |
+
dout_r <= bytecnt[0] ? hdd_data_in[7:0] : hdd_data_in[15:8];
|
| 139 |
+
|
| 140 |
+
CMD_IDE_CDDA_RD:
|
| 141 |
+
dout_r <= {7'd0, hdd_cdda_req};
|
| 142 |
+
|
| 143 |
+
DIO_FILE_RX_DAT:
|
| 144 |
+
dout_r <= ioctl_din;
|
| 145 |
+
|
| 146 |
+
default: oe <= 0;
|
| 147 |
+
endcase
|
| 148 |
+
end
|
| 149 |
+
|
| 150 |
+
if (cnt == 7 && {sbuf, SPI_DI} == DIO_FILE_RX_DAT) oe <= 1;
|
| 151 |
+
|
| 152 |
+
reg_do <= (!cnt[3] && ENABLE_IDE == 1) ? cmdcode[~cnt[2:0]] : oe ? dout_r[~cnt[2:0]] : 1'bZ;
|
| 153 |
+
end
|
| 154 |
+
end
|
| 155 |
+
|
| 156 |
+
|
| 157 |
+
always@(posedge SPI_SCK, posedge SPI_SS2) begin : SPI_RECEIVER
|
| 158 |
+
if(SPI_SS2) begin
|
| 159 |
+
bytecnt <= 0;
|
| 160 |
+
cnt <= 0;
|
| 161 |
+
end else begin
|
| 162 |
+
// don't shift in last bit. It is evaluated directly
|
| 163 |
+
// when writing to ram
|
| 164 |
+
if(cnt != 15) sbuf <= { sbuf[5:0], SPI_DI};
|
| 165 |
+
|
| 166 |
+
// count 0-7 8-15 8-15 ...
|
| 167 |
+
if(cnt != 15) cnt <= cnt + 1'd1;
|
| 168 |
+
else cnt <= 8;
|
| 169 |
+
|
| 170 |
+
// finished command byte
|
| 171 |
+
if(cnt == 7) cmd <= {sbuf, SPI_DI};
|
| 172 |
+
|
| 173 |
+
if(cnt == 15) begin
|
| 174 |
+
if (~&bytecnt) bytecnt <= bytecnt + 1'd1;
|
| 175 |
+
else bytecnt[0] <= ~bytecnt[0];
|
| 176 |
+
|
| 177 |
+
case (cmd)
|
| 178 |
+
// prepare/end transmission
|
| 179 |
+
DIO_FILE_TX: begin
|
| 180 |
+
// prepare
|
| 181 |
+
if(SPI_DI) begin
|
| 182 |
+
addr_reset <= ~addr_reset;
|
| 183 |
+
downloading_reg <= 1;
|
| 184 |
+
end else begin
|
| 185 |
+
downloading_reg <= 0;
|
| 186 |
+
end
|
| 187 |
+
end
|
| 188 |
+
|
| 189 |
+
DIO_FILE_RX: begin
|
| 190 |
+
// prepare
|
| 191 |
+
if(SPI_DI) begin
|
| 192 |
+
addr_reset <= ~addr_reset;
|
| 193 |
+
uploading_reg <= 1;
|
| 194 |
+
end else begin
|
| 195 |
+
uploading_reg <= 0;
|
| 196 |
+
end
|
| 197 |
+
end
|
| 198 |
+
|
| 199 |
+
// command 0x57: DIO_FILE_RX_DAT
|
| 200 |
+
// command 0x54: DIO_FILE_TX_DAT
|
| 201 |
+
DIO_FILE_RX_DAT,
|
| 202 |
+
DIO_FILE_TX_DAT: begin
|
| 203 |
+
data_w <= {sbuf, SPI_DI};
|
| 204 |
+
rclk <= ~rclk;
|
| 205 |
+
end
|
| 206 |
+
|
| 207 |
+
// expose file (menu) index
|
| 208 |
+
DIO_FILE_INDEX: ioctl_index <= {sbuf, SPI_DI};
|
| 209 |
+
|
| 210 |
+
// receiving FAT directory entry (mist-firmware/fat.h - DIRENTRY)
|
| 211 |
+
DIO_FILE_INFO: begin
|
| 212 |
+
case (bytecnt)
|
| 213 |
+
8'h08: ioctl_fileext[23:16] <= {sbuf, SPI_DI};
|
| 214 |
+
8'h09: ioctl_fileext[15: 8] <= {sbuf, SPI_DI};
|
| 215 |
+
8'h0A: ioctl_fileext[ 7: 0] <= {sbuf, SPI_DI};
|
| 216 |
+
8'h1C: ioctl_filesize[ 7: 0] <= {sbuf, SPI_DI};
|
| 217 |
+
8'h1D: ioctl_filesize[15: 8] <= {sbuf, SPI_DI};
|
| 218 |
+
8'h1E: ioctl_filesize[23:16] <= {sbuf, SPI_DI};
|
| 219 |
+
8'h1F: ioctl_filesize[31:24] <= {sbuf, SPI_DI};
|
| 220 |
+
endcase
|
| 221 |
+
end
|
| 222 |
+
endcase
|
| 223 |
+
end
|
| 224 |
+
end
|
| 225 |
+
end
|
| 226 |
+
|
| 227 |
+
// direct SD Card->FPGA transfer
|
| 228 |
+
generate if (ROM_DIRECT_UPLOAD == 1 || ENABLE_IDE == 1) begin
|
| 229 |
+
|
| 230 |
+
always@(posedge SPI_SCK, posedge SPI_SS4) begin : SPI_DIRECT_RECEIVER
|
| 231 |
+
reg [6:0] sbuf2;
|
| 232 |
+
reg [2:0] cnt2;
|
| 233 |
+
reg [9:0] bytecnt;
|
| 234 |
+
|
| 235 |
+
if(SPI_SS4) begin
|
| 236 |
+
cnt2 <= 0;
|
| 237 |
+
bytecnt <= 0;
|
| 238 |
+
end else begin
|
| 239 |
+
// don't shift in last bit. It is evaluated directly
|
| 240 |
+
// when writing to ram
|
| 241 |
+
if(cnt2 != 7)
|
| 242 |
+
sbuf2 <= { sbuf2[5:0], SPI_DO };
|
| 243 |
+
|
| 244 |
+
cnt2 <= cnt2 + 1'd1;
|
| 245 |
+
|
| 246 |
+
// received a byte
|
| 247 |
+
if(cnt2 == 7) begin
|
| 248 |
+
bytecnt <= bytecnt + 1'd1;
|
| 249 |
+
// read 514 byte/sector (512 + 2 CRC)
|
| 250 |
+
if (bytecnt == 513) bytecnt <= 0;
|
| 251 |
+
// don't send the CRC bytes
|
| 252 |
+
if (~bytecnt[9]) begin
|
| 253 |
+
data_w2 <= {sbuf2, SPI_DO};
|
| 254 |
+
rclk2 <= ~rclk2;
|
| 255 |
+
end
|
| 256 |
+
end
|
| 257 |
+
end
|
| 258 |
+
end
|
| 259 |
+
|
| 260 |
+
end
|
| 261 |
+
endgenerate
|
| 262 |
+
|
| 263 |
+
// QSPI receiver
|
| 264 |
+
generate if (USE_QSPI == 1) begin
|
| 265 |
+
|
| 266 |
+
always@(negedge QSCK, posedge QCSn) begin : QSPI_RECEIVER
|
| 267 |
+
reg [1:0] nibble;
|
| 268 |
+
reg cmd_got;
|
| 269 |
+
reg cmd_write;
|
| 270 |
+
|
| 271 |
+
if (QCSn) begin
|
| 272 |
+
cmd_got <= 0;
|
| 273 |
+
cmd_write <= 0;
|
| 274 |
+
nibble <= 0;
|
| 275 |
+
end else begin
|
| 276 |
+
nibble <= nibble + 1'd1;
|
| 277 |
+
data_w3 <= {data_w3[11:0], QDAT};
|
| 278 |
+
if (!cmd_got) begin
|
| 279 |
+
// first byte is the command
|
| 280 |
+
if (nibble[0]) begin
|
| 281 |
+
nibble <= 0;
|
| 282 |
+
cmd_got <= 1;
|
| 283 |
+
if ({data_w3[3:0], QDAT} == QSPI_WRITE) cmd_write <= 1;
|
| 284 |
+
end
|
| 285 |
+
end else if ((DOUT_16 == 1 && &nibble) || (DOUT_16 == 0 && nibble[0])) begin
|
| 286 |
+
if (cmd_write) rclk3 <= ~rclk3;
|
| 287 |
+
end
|
| 288 |
+
end
|
| 289 |
+
end
|
| 290 |
+
end
|
| 291 |
+
endgenerate
|
| 292 |
+
|
| 293 |
+
reg wr_int, wr_int_direct, rd_int;
|
| 294 |
+
wire [7:0] ioctl_dout_next = wr_int ? data_w : data_w2;
|
| 295 |
+
|
| 296 |
+
always@(posedge clk_sys) begin : DATA_OUT
|
| 297 |
+
// synchronisers
|
| 298 |
+
reg rclkD, rclkD2;
|
| 299 |
+
reg rclk2D, rclk2D2;
|
| 300 |
+
reg rclk3D, rclk3D2;
|
| 301 |
+
reg addr_resetD, addr_resetD2;
|
| 302 |
+
|
| 303 |
+
reg [26:0] addr;
|
| 304 |
+
reg [31:0] filepos;
|
| 305 |
+
reg [7:0] tmp;
|
| 306 |
+
|
| 307 |
+
// bring flags from spi clock domain into core clock domain
|
| 308 |
+
{ rclkD, rclkD2 } <= { rclk, rclkD };
|
| 309 |
+
{ rclk2D ,rclk2D2 } <= { rclk2, rclk2D };
|
| 310 |
+
{ rclk3D ,rclk3D2 } <= { rclk3, rclk3D };
|
| 311 |
+
{ addr_resetD, addr_resetD2 } <= { addr_reset, addr_resetD };
|
| 312 |
+
|
| 313 |
+
ioctl_wr <= 0;
|
| 314 |
+
|
| 315 |
+
if (!downloading_reg) begin
|
| 316 |
+
ioctl_download <= 0;
|
| 317 |
+
wr_int <= 0;
|
| 318 |
+
wr_int_direct <= 0;
|
| 319 |
+
end
|
| 320 |
+
|
| 321 |
+
if (!uploading_reg) begin
|
| 322 |
+
ioctl_upload <= 0;
|
| 323 |
+
rd_int <= 0;
|
| 324 |
+
end
|
| 325 |
+
|
| 326 |
+
if (~clkref_n) begin
|
| 327 |
+
rd_int <= 0;
|
| 328 |
+
wr_int <= 0;
|
| 329 |
+
wr_int_direct <= 0;
|
| 330 |
+
if (wr_int || wr_int_direct) begin
|
| 331 |
+
if (DOUT_16 == 1) begin
|
| 332 |
+
if (addr[0]) begin
|
| 333 |
+
ioctl_dout <= {ioctl_dout_next, tmp};
|
| 334 |
+
ioctl_wr <= 1;
|
| 335 |
+
ioctl_addr <= {addr[26:1], 1'b0};
|
| 336 |
+
end else
|
| 337 |
+
tmp <= ioctl_dout_next;
|
| 338 |
+
end else begin
|
| 339 |
+
ioctl_dout <= ioctl_dout_next;
|
| 340 |
+
ioctl_wr <= 1;
|
| 341 |
+
ioctl_addr <= addr;
|
| 342 |
+
end
|
| 343 |
+
addr <= addr + 1'd1;
|
| 344 |
+
end
|
| 345 |
+
if (rd_int) begin
|
| 346 |
+
ioctl_addr <= ioctl_addr + 1'd1;
|
| 347 |
+
end
|
| 348 |
+
end
|
| 349 |
+
|
| 350 |
+
// detect transfer start from the SPI receiver
|
| 351 |
+
if(addr_resetD ^ addr_resetD2) begin
|
| 352 |
+
addr <= START_ADDR;
|
| 353 |
+
ioctl_addr <= START_ADDR;
|
| 354 |
+
filepos <= 0;
|
| 355 |
+
ioctl_download <= downloading_reg;
|
| 356 |
+
ioctl_upload <= uploading_reg;
|
| 357 |
+
end
|
| 358 |
+
|
| 359 |
+
// detect new byte from the SPI receiver
|
| 360 |
+
if (rclkD ^ rclkD2) begin
|
| 361 |
+
wr_int <= downloading_reg;
|
| 362 |
+
rd_int <= uploading_reg;
|
| 363 |
+
end
|
| 364 |
+
// direct transfer receiver
|
| 365 |
+
if ((rclk2D ^ rclk2D2) & (filepos != ioctl_filesize) & downloading_reg) begin
|
| 366 |
+
filepos <= filepos + 1'd1;
|
| 367 |
+
wr_int_direct <= 1;
|
| 368 |
+
end
|
| 369 |
+
// QSPI transfer receiver
|
| 370 |
+
if (rclk3D ^ rclk3D2) begin
|
| 371 |
+
ioctl_wr <= 1;
|
| 372 |
+
ioctl_addr <= addr;
|
| 373 |
+
if (DOUT_16 == 1) begin
|
| 374 |
+
addr <= addr + 2'd2;
|
| 375 |
+
ioctl_dout <= data_w3;
|
| 376 |
+
end else begin
|
| 377 |
+
addr <= addr + 1'd1;
|
| 378 |
+
ioctl_dout <= data_w3[7:0];
|
| 379 |
+
end
|
| 380 |
+
end
|
| 381 |
+
|
| 382 |
+
end
|
| 383 |
+
|
| 384 |
+
// IDE handling
|
| 385 |
+
generate if (ENABLE_IDE == 1) begin
|
| 386 |
+
|
| 387 |
+
reg [1:0] int_hdd0_ena;
|
| 388 |
+
reg [1:0] int_hdd1_ena;
|
| 389 |
+
reg int_hdd_cdda_wr;
|
| 390 |
+
reg int_hdd_status_wr;
|
| 391 |
+
reg [2:0] int_hdd_addr = 0;
|
| 392 |
+
reg int_hdd_wr;
|
| 393 |
+
reg [15:0] int_hdd_data_out;
|
| 394 |
+
reg int_hdd_data_rd;
|
| 395 |
+
reg int_hdd_data_wr;
|
| 396 |
+
|
| 397 |
+
assign hdd0_ena = int_hdd0_ena;
|
| 398 |
+
assign hdd1_ena = int_hdd1_ena;
|
| 399 |
+
assign hdd_cdda_wr = int_hdd_cdda_wr;
|
| 400 |
+
assign hdd_status_wr = int_hdd_status_wr;
|
| 401 |
+
assign hdd_addr = int_hdd_addr;
|
| 402 |
+
assign hdd_wr = int_hdd_wr;
|
| 403 |
+
assign hdd_data_out = int_hdd_data_out;
|
| 404 |
+
assign hdd_data_rd = int_hdd_data_rd;
|
| 405 |
+
assign hdd_data_wr = int_hdd_data_wr;
|
| 406 |
+
|
| 407 |
+
reg rst0 = 1;
|
| 408 |
+
reg rst2 = 1;
|
| 409 |
+
reg rclk_ide_stat = 0;
|
| 410 |
+
reg rclk_ide_regs_rd = 0;
|
| 411 |
+
reg rclk_ide_regs_wr = 0;
|
| 412 |
+
reg rclk_ide_wr = 0;
|
| 413 |
+
reg rclk_ide_rd = 0;
|
| 414 |
+
reg rclk_cdda_wr = 0;
|
| 415 |
+
reg [7:0] data_ide;
|
| 416 |
+
|
| 417 |
+
always@(posedge SPI_SCK, posedge SPI_SS2) begin : SPI_RECEIVER_IDE
|
| 418 |
+
if(SPI_SS2) begin
|
| 419 |
+
rst0 <= 1;
|
| 420 |
+
end else begin
|
| 421 |
+
rst0 <= 0;
|
| 422 |
+
|
| 423 |
+
if(cnt == 15) begin
|
| 424 |
+
|
| 425 |
+
case (cmd)
|
| 426 |
+
//IDE commands
|
| 427 |
+
CMD_IDE_CFG_WR:
|
| 428 |
+
if (bytecnt == 0) begin
|
| 429 |
+
int_hdd0_ena <= {sbuf[0], SPI_DI};
|
| 430 |
+
int_hdd1_ena <= sbuf[2:1];
|
| 431 |
+
end
|
| 432 |
+
|
| 433 |
+
CMD_IDE_STATUS_WR:
|
| 434 |
+
if (bytecnt == 0) begin
|
| 435 |
+
data_ide <= {sbuf, SPI_DI};
|
| 436 |
+
rclk_ide_stat <= ~rclk_ide_stat;
|
| 437 |
+
end
|
| 438 |
+
|
| 439 |
+
CMD_IDE_REGS_WR:
|
| 440 |
+
if (bytecnt >= 8 && bytecnt <= 18 && !bytecnt[0]) begin
|
| 441 |
+
data_ide <= {sbuf, SPI_DI};
|
| 442 |
+
rclk_ide_regs_wr <= ~rclk_ide_regs_wr;
|
| 443 |
+
end
|
| 444 |
+
|
| 445 |
+
CMD_IDE_REGS_RD:
|
| 446 |
+
if (bytecnt > 5 && !bytecnt[0]) begin
|
| 447 |
+
rclk_ide_regs_rd <= ~rclk_ide_regs_rd;
|
| 448 |
+
end
|
| 449 |
+
|
| 450 |
+
CMD_IDE_DATA_WR:
|
| 451 |
+
if (bytecnt > 4) begin
|
| 452 |
+
data_ide <= {sbuf, SPI_DI};
|
| 453 |
+
rclk_ide_wr <= ~rclk_ide_wr;
|
| 454 |
+
end
|
| 455 |
+
|
| 456 |
+
CMD_IDE_CDDA_WR:
|
| 457 |
+
if (bytecnt > 4) begin
|
| 458 |
+
data_ide <= {sbuf, SPI_DI};
|
| 459 |
+
rclk_cdda_wr <= ~rclk_cdda_wr;
|
| 460 |
+
end
|
| 461 |
+
|
| 462 |
+
CMD_IDE_DATA_RD:
|
| 463 |
+
if (bytecnt > 3) rclk_ide_rd <= ~rclk_ide_rd;
|
| 464 |
+
|
| 465 |
+
endcase
|
| 466 |
+
end
|
| 467 |
+
end
|
| 468 |
+
end
|
| 469 |
+
|
| 470 |
+
always@(posedge SPI_SCK, posedge SPI_SS4) begin : SPI_DIRECT_RECEIVER_IDE
|
| 471 |
+
if(SPI_SS4) begin
|
| 472 |
+
rst2 <= 1;
|
| 473 |
+
end else begin
|
| 474 |
+
rst2 <= 0;
|
| 475 |
+
end
|
| 476 |
+
end
|
| 477 |
+
|
| 478 |
+
always@(posedge hdd_clk) begin : IDE_OUT
|
| 479 |
+
reg loword;
|
| 480 |
+
|
| 481 |
+
// synchronisers
|
| 482 |
+
reg rclk2D, rclk2D2;
|
| 483 |
+
reg rclk_ide_statD, rclk_ide_statD2;
|
| 484 |
+
reg rclk_cdda_wrD, rclk_cdda_wrD2;
|
| 485 |
+
reg rclk_ide_wrD, rclk_ide_wrD2;
|
| 486 |
+
reg rclk_ide_rdD, rclk_ide_rdD2;
|
| 487 |
+
reg rclk_ide_regs_wrD, rclk_ide_regs_wrD2;
|
| 488 |
+
reg rclk_ide_regs_rdD, rclk_ide_regs_rdD2;
|
| 489 |
+
reg rst0D, rst0D2;
|
| 490 |
+
reg rst2D, rst2D2;
|
| 491 |
+
|
| 492 |
+
// bring flags from spi clock domain into core clock domain
|
| 493 |
+
{ rclk2D ,rclk2D2 } <= { rclk2, rclk2D };
|
| 494 |
+
{ rclk_ide_statD, rclk_ide_statD2 } <= { rclk_ide_stat, rclk_ide_statD };
|
| 495 |
+
{ rclk_ide_rdD, rclk_ide_rdD2 } <= { rclk_ide_rd, rclk_ide_rdD };
|
| 496 |
+
{ rclk_ide_wrD, rclk_ide_wrD2 } <= { rclk_ide_wr, rclk_ide_wrD };
|
| 497 |
+
{ rclk_cdda_wrD, rclk_cdda_wrD2 } <= { rclk_cdda_wr, rclk_cdda_wrD };
|
| 498 |
+
{ rclk_ide_regs_rdD, rclk_ide_regs_rdD2 } <= { rclk_ide_regs_rd, rclk_ide_regs_rdD };
|
| 499 |
+
{ rclk_ide_regs_wrD, rclk_ide_regs_wrD2 } <= { rclk_ide_regs_wr, rclk_ide_regs_wrD };
|
| 500 |
+
{ rst0D, rst0D2 } <= { rst0, rst0D };
|
| 501 |
+
{ rst2D, rst2D2 } <= { rst2, rst2D };
|
| 502 |
+
|
| 503 |
+
// IDE receiver
|
| 504 |
+
int_hdd_wr <= 0;
|
| 505 |
+
int_hdd_status_wr <= 0;
|
| 506 |
+
int_hdd_data_wr <= 0;
|
| 507 |
+
int_hdd_data_rd <= 0;
|
| 508 |
+
int_hdd_cdda_wr <= 0;
|
| 509 |
+
|
| 510 |
+
if (rst0D2) int_hdd_addr <= 0;
|
| 511 |
+
if (rst0D2 && rst2D2) loword <= 0;
|
| 512 |
+
|
| 513 |
+
if (rclk_ide_statD ^ rclk_ide_statD2) begin
|
| 514 |
+
int_hdd_status_wr <= 1;
|
| 515 |
+
int_hdd_data_out <= {8'h00, data_ide};
|
| 516 |
+
end
|
| 517 |
+
if (rclk_ide_rdD ^ rclk_ide_rdD2) begin
|
| 518 |
+
loword <= ~loword;
|
| 519 |
+
if (loword)
|
| 520 |
+
int_hdd_data_rd <= 1;
|
| 521 |
+
end
|
| 522 |
+
if (rclk_ide_wrD ^ rclk_ide_wrD2) begin
|
| 523 |
+
loword <= ~loword;
|
| 524 |
+
if (!loword)
|
| 525 |
+
int_hdd_data_out[15:8] <= data_ide;
|
| 526 |
+
else begin
|
| 527 |
+
int_hdd_data_wr <= 1;
|
| 528 |
+
int_hdd_data_out[7:0] <= data_ide;
|
| 529 |
+
end
|
| 530 |
+
end
|
| 531 |
+
if (rclk_cdda_wrD ^ rclk_cdda_wrD2) begin
|
| 532 |
+
loword <= ~loword;
|
| 533 |
+
if (!loword)
|
| 534 |
+
int_hdd_data_out[15:8] <= data_ide;
|
| 535 |
+
else begin
|
| 536 |
+
int_hdd_cdda_wr <= 1;
|
| 537 |
+
int_hdd_data_out[7:0] <= data_ide;
|
| 538 |
+
end
|
| 539 |
+
end
|
| 540 |
+
if ((rclk2D ^ rclk2D2) & ~downloading_reg) begin
|
| 541 |
+
loword <= ~loword;
|
| 542 |
+
if (!loword)
|
| 543 |
+
int_hdd_data_out[15:8] <= data_w2;
|
| 544 |
+
else begin
|
| 545 |
+
int_hdd_data_wr <= 1;
|
| 546 |
+
int_hdd_data_out[7:0] <= data_w2;
|
| 547 |
+
end
|
| 548 |
+
end
|
| 549 |
+
if (rclk_ide_regs_wrD ^ rclk_ide_regs_wrD2) begin
|
| 550 |
+
int_hdd_wr <= 1;
|
| 551 |
+
int_hdd_data_out <= {8'h00, data_ide};
|
| 552 |
+
int_hdd_addr <= int_hdd_addr + 1'd1;
|
| 553 |
+
end
|
| 554 |
+
if (rclk_ide_regs_rdD ^ rclk_ide_regs_rdD2) begin
|
| 555 |
+
int_hdd_addr <= int_hdd_addr + 1'd1;
|
| 556 |
+
end
|
| 557 |
+
end
|
| 558 |
+
end else begin
|
| 559 |
+
assign hdd0_ena = 0;
|
| 560 |
+
assign hdd1_ena = 0;
|
| 561 |
+
assign hdd_cdda_wr = 0;
|
| 562 |
+
assign hdd_status_wr = 0;
|
| 563 |
+
assign hdd_addr = 0;
|
| 564 |
+
assign hdd_wr = 0;
|
| 565 |
+
assign hdd_data_out = 0;
|
| 566 |
+
assign hdd_data_rd = 0;
|
| 567 |
+
assign hdd_data_wr = 0;
|
| 568 |
+
end
|
| 569 |
+
|
| 570 |
+
endgenerate
|
| 571 |
+
|
| 572 |
+
endmodule
|
snapshots/jotego_jtcores_pr1270/modules/jtframe/target/mist/hdl/i2c_master.v
ADDED
|
@@ -0,0 +1,111 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// taken and tweaked from MiSTer sys/
|
| 2 |
+
module i2c_master
|
| 3 |
+
(
|
| 4 |
+
input CLK,
|
| 5 |
+
|
| 6 |
+
input I2C_START,
|
| 7 |
+
input I2C_READ,
|
| 8 |
+
input [6:0] I2C_ADDR,
|
| 9 |
+
input [7:0] I2C_SUBADDR,
|
| 10 |
+
input [7:0] I2C_WDATA,
|
| 11 |
+
output [7:0] I2C_RDATA,
|
| 12 |
+
output reg I2C_END = 1,
|
| 13 |
+
output reg I2C_ACK = 0,
|
| 14 |
+
|
| 15 |
+
//I2C bus
|
| 16 |
+
inout I2C_SCL,
|
| 17 |
+
inout I2C_SDA
|
| 18 |
+
);
|
| 19 |
+
|
| 20 |
+
|
| 21 |
+
// Clock Setting
|
| 22 |
+
parameter CLK_Freq = 50_000_000; // 50 MHz
|
| 23 |
+
parameter I2C_Freq = 400_000; // 400 KHz
|
| 24 |
+
|
| 25 |
+
localparam I2C_FreqX2 = I2C_Freq*2;
|
| 26 |
+
|
| 27 |
+
reg I2C_CLOCK;
|
| 28 |
+
reg [31:0] cnt;
|
| 29 |
+
wire [31:0] cnt_next = cnt + I2C_FreqX2;
|
| 30 |
+
|
| 31 |
+
always @(posedge CLK) begin
|
| 32 |
+
cnt <= cnt_next;
|
| 33 |
+
if(cnt_next >= CLK_Freq) begin
|
| 34 |
+
cnt <= cnt_next - CLK_Freq;
|
| 35 |
+
I2C_CLOCK <= ~I2C_CLOCK;
|
| 36 |
+
end
|
| 37 |
+
end
|
| 38 |
+
|
| 39 |
+
reg SCLK;
|
| 40 |
+
reg [15:0] SDO;
|
| 41 |
+
reg [0:7] rdata;
|
| 42 |
+
|
| 43 |
+
reg [6:0] SD_COUNTER;
|
| 44 |
+
reg [0:42] SD;
|
| 45 |
+
|
| 46 |
+
assign I2C_SCL = (SCLK | I2C_CLOCK) ? 1'bZ : 1'b0;
|
| 47 |
+
assign I2C_SDA = SDO[15] ? 1'bZ : 1'b0;
|
| 48 |
+
|
| 49 |
+
initial begin
|
| 50 |
+
SD_COUNTER = 'b1111111;
|
| 51 |
+
SD = {40'hFFFFFFFFFF, 3'b111};
|
| 52 |
+
SCLK = 1;
|
| 53 |
+
SDO = 16'hFFFF;
|
| 54 |
+
end
|
| 55 |
+
|
| 56 |
+
assign I2C_RDATA = rdata;
|
| 57 |
+
|
| 58 |
+
always @(posedge CLK) begin : b0
|
| 59 |
+
reg old_clk;
|
| 60 |
+
reg old_st;
|
| 61 |
+
reg rd;
|
| 62 |
+
reg sda_in;
|
| 63 |
+
|
| 64 |
+
old_clk <= I2C_CLOCK;
|
| 65 |
+
old_st <= I2C_START;
|
| 66 |
+
sda_in <= I2C_SDA;
|
| 67 |
+
|
| 68 |
+
// delay to make sure SDA changed while SCL is stabilized at low
|
| 69 |
+
if(old_clk && ~I2C_CLOCK && ~SD_COUNTER[6]) SDO[0] <= SD[SD_COUNTER[5:0]];
|
| 70 |
+
SDO[15:1] <= SDO[14:0];
|
| 71 |
+
|
| 72 |
+
if(~old_st && I2C_START) begin
|
| 73 |
+
SCLK <= 1;
|
| 74 |
+
SDO <= 16'hFFFF;
|
| 75 |
+
I2C_ACK <= 0;
|
| 76 |
+
I2C_END <= 0;
|
| 77 |
+
rd <= I2C_READ;
|
| 78 |
+
if(I2C_READ) SD[0:42] <= {2'b10, I2C_ADDR, 1'b0, 1'b1, I2C_SUBADDR, 3'b110, I2C_ADDR, 1'b1, 1'b1, 8'b11111111, 4'b1011};
|
| 79 |
+
else SD[0:31] <= {2'b10, I2C_ADDR, 1'b0, 1'b1, I2C_SUBADDR, 1'b1, I2C_WDATA, 4'b1011};
|
| 80 |
+
SD_COUNTER <= 0;
|
| 81 |
+
end else begin
|
| 82 |
+
if(~old_clk && I2C_CLOCK && ~SD_COUNTER[6]) begin
|
| 83 |
+
SD_COUNTER <= SD_COUNTER + 6'd1;
|
| 84 |
+
case(SD_COUNTER)
|
| 85 |
+
01: SCLK <= 0;
|
| 86 |
+
10: I2C_ACK <= ~sda_in;
|
| 87 |
+
19: I2C_ACK <= ~sda_in;
|
| 88 |
+
20: if (rd) SCLK <= 1; // repeated start
|
| 89 |
+
21: if (rd) SCLK <= 0;
|
| 90 |
+
28: if (~rd) I2C_ACK <= ~sda_in;
|
| 91 |
+
29: if (~rd) SCLK <= 1;
|
| 92 |
+
30: if (rd) I2C_ACK <= ~sda_in;
|
| 93 |
+
32: if (~rd) begin
|
| 94 |
+
I2C_END <= 1;
|
| 95 |
+
SD_COUNTER <= 64;
|
| 96 |
+
end
|
| 97 |
+
40: SCLK <= 1;
|
| 98 |
+
42: begin
|
| 99 |
+
I2C_END <= 1;
|
| 100 |
+
SD_COUNTER <= 64;
|
| 101 |
+
end
|
| 102 |
+
64: SCLK <= 1;
|
| 103 |
+
default: ;
|
| 104 |
+
endcase
|
| 105 |
+
|
| 106 |
+
if(SD_COUNTER >= 31 && SD_COUNTER <= 38) rdata[SD_COUNTER[5:0]-31] <= sda_in;
|
| 107 |
+
end
|
| 108 |
+
end
|
| 109 |
+
end
|
| 110 |
+
|
| 111 |
+
endmodule
|
snapshots/jotego_jtcores_pr1270/modules/jtframe/target/mist/hdl/i2s.v
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// taken and tweaked from MiSTer sys/
|
| 2 |
+
|
| 3 |
+
module i2s #(parameter
|
| 4 |
+
// Clock Setting
|
| 5 |
+
I2S_Freq = 48_000, // 48 KHz
|
| 6 |
+
AUDIO_DW = 16
|
| 7 |
+
)(
|
| 8 |
+
input reset,
|
| 9 |
+
input clk,
|
| 10 |
+
input [31:0] clk_rate,
|
| 11 |
+
|
| 12 |
+
output reg sclk,
|
| 13 |
+
output reg lrclk,
|
| 14 |
+
output reg sdata,
|
| 15 |
+
|
| 16 |
+
input [AUDIO_DW-1:0] left_chan,
|
| 17 |
+
input [AUDIO_DW-1:0] right_chan
|
| 18 |
+
);
|
| 19 |
+
|
| 20 |
+
|
| 21 |
+
localparam I2S_FreqX2 = I2S_Freq*2*AUDIO_DW*2;
|
| 22 |
+
|
| 23 |
+
reg [31:0] cnt;
|
| 24 |
+
wire [31:0] cnt_next = cnt + I2S_FreqX2;
|
| 25 |
+
reg ce;
|
| 26 |
+
reg [ 4:0] bit_cnt = 1;
|
| 27 |
+
|
| 28 |
+
reg [AUDIO_DW-1:0] left;
|
| 29 |
+
reg [AUDIO_DW-1:0] right;
|
| 30 |
+
|
| 31 |
+
always @(posedge clk) begin
|
| 32 |
+
ce <= 0;
|
| 33 |
+
cnt <= cnt_next;
|
| 34 |
+
if(cnt_next >= clk_rate) begin
|
| 35 |
+
cnt <= cnt_next - clk_rate;
|
| 36 |
+
ce <= 1;
|
| 37 |
+
end
|
| 38 |
+
end
|
| 39 |
+
|
| 40 |
+
|
| 41 |
+
always @(posedge clk) begin
|
| 42 |
+
if (reset) begin
|
| 43 |
+
bit_cnt <= 1;
|
| 44 |
+
lrclk <= 1;
|
| 45 |
+
sclk <= 1;
|
| 46 |
+
sdata <= 1;
|
| 47 |
+
sclk <= 1;
|
| 48 |
+
end
|
| 49 |
+
else begin
|
| 50 |
+
if(ce) begin
|
| 51 |
+
sclk <= ~sclk;
|
| 52 |
+
if(sclk) begin
|
| 53 |
+
if(bit_cnt == AUDIO_DW) begin
|
| 54 |
+
bit_cnt <= 1;
|
| 55 |
+
lrclk <= ~lrclk;
|
| 56 |
+
if(lrclk) begin
|
| 57 |
+
left <= left_chan;
|
| 58 |
+
right <= right_chan;
|
| 59 |
+
end
|
| 60 |
+
end
|
| 61 |
+
else begin
|
| 62 |
+
bit_cnt <= bit_cnt + 1'd1;
|
| 63 |
+
end
|
| 64 |
+
sdata <= lrclk ? right[AUDIO_DW - bit_cnt] : left[AUDIO_DW - bit_cnt];
|
| 65 |
+
end
|
| 66 |
+
end
|
| 67 |
+
end
|
| 68 |
+
end
|
| 69 |
+
|
| 70 |
+
endmodule
|
snapshots/jotego_jtcores_pr1270/modules/jtframe/target/mist/hdl/jtframe_mist.sv
ADDED
|
@@ -0,0 +1,534 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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JTFRAME program is free software: you can redistribute it and/or modify
|
| 3 |
+
it under the terms of the GNU General Public License as published by
|
| 4 |
+
the Free Software Foundation, either version 3 of the License, or
|
| 5 |
+
(at your option) any later version.
|
| 6 |
+
|
| 7 |
+
JTFRAME program is distributed in the hope that it will be useful,
|
| 8 |
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
| 9 |
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
| 10 |
+
GNU General Public License for more details.
|
| 11 |
+
|
| 12 |
+
You should have received a copy of the GNU General Public License
|
| 13 |
+
along with JTFRAME. If not, see <http://www.gnu.org/licenses/>.
|
| 14 |
+
|
| 15 |
+
Author: Jose Tejada Gomez. Twitter: @topapate
|
| 16 |
+
Version: 1.0
|
| 17 |
+
Date: 7-3-2019 */
|
| 18 |
+
|
| 19 |
+
module jtframe_mist #(parameter
|
| 20 |
+
SIGNED_SND = 1'b0,
|
| 21 |
+
BUTTONS = 2,
|
| 22 |
+
DIPBASE = 16,
|
| 23 |
+
GAME_INPUTS_ACTIVE_LOW = 1'b1,
|
| 24 |
+
COLORW = 4,
|
| 25 |
+
VIDEO_WIDTH = 384,
|
| 26 |
+
VIDEO_HEIGHT = 224,
|
| 27 |
+
SDRAMW = 23,
|
| 28 |
+
VGA_DW = 6,
|
| 29 |
+
QSPI = 1'b0,
|
| 30 |
+
HDMI = 1'b0,
|
| 31 |
+
XOR_ROT = 1'b0
|
| 32 |
+
)(
|
| 33 |
+
input clk_sys,
|
| 34 |
+
input clk_rom,
|
| 35 |
+
input clk_pico,
|
| 36 |
+
input pll_locked,
|
| 37 |
+
// interface with microcontroller
|
| 38 |
+
output [63:0] status,
|
| 39 |
+
output [31:0] dipsw,
|
| 40 |
+
// Base video
|
| 41 |
+
input [COLORW-1:0] game_r, game_g, game_b,
|
| 42 |
+
input LHBL,
|
| 43 |
+
input LVBL,
|
| 44 |
+
input hs,
|
| 45 |
+
input vs,
|
| 46 |
+
inout pxl2_cen,
|
| 47 |
+
inout pxl_cen,
|
| 48 |
+
// MiST VGA pins
|
| 49 |
+
output [VGA_DW-1:0] VGA_R, VGA_G, VGA_B,
|
| 50 |
+
output VGA_HS,
|
| 51 |
+
output VGA_VS,
|
| 52 |
+
// HDMI pins
|
| 53 |
+
output [7:0] HDMI_R,
|
| 54 |
+
output [7:0] HDMI_G,
|
| 55 |
+
output [7:0] HDMI_B,
|
| 56 |
+
output HDMI_HS,
|
| 57 |
+
output HDMI_VS,
|
| 58 |
+
output HDMI_PCLK,
|
| 59 |
+
output HDMI_DE,
|
| 60 |
+
inout HDMI_SDA,
|
| 61 |
+
inout HDMI_SCL,
|
| 62 |
+
// ROM programming
|
| 63 |
+
input [SDRAMW-1:0] prog_addr,
|
| 64 |
+
input [15:0] prog_data,
|
| 65 |
+
input [ 1:0] prog_mask, prog_ba,
|
| 66 |
+
input prog_we,
|
| 67 |
+
input prog_rd,
|
| 68 |
+
output prog_dst,
|
| 69 |
+
output prog_dok,
|
| 70 |
+
output prog_rdy,
|
| 71 |
+
output prog_ack,
|
| 72 |
+
// ROM access from game
|
| 73 |
+
input [SDRAMW-1:0] ba0_addr,ba1_addr,ba2_addr,ba3_addr,
|
| 74 |
+
input [3:0] ba_rd, ba_wr,
|
| 75 |
+
output [3:0] ba_ack, ba_rdy, ba_dst, ba_dok,
|
| 76 |
+
input [15:0] ba0_din, ba1_din, ba2_din, ba3_din,
|
| 77 |
+
input [ 1:0] ba0_dsn, ba1_dsn, ba2_dsn, ba3_dsn,
|
| 78 |
+
output [15:0] sdram_dout,
|
| 79 |
+
// UART
|
| 80 |
+
input uart_rx,
|
| 81 |
+
output uart_tx,
|
| 82 |
+
// SDRAM interface
|
| 83 |
+
inout [15:0] SDRAM_DQ, // SDRAM Data bus 16 Bits
|
| 84 |
+
output [12:0] SDRAM_A, // SDRAM Address bus 13 Bits
|
| 85 |
+
output SDRAM_DQML, // SDRAM Low-byte Data Mask
|
| 86 |
+
output SDRAM_DQMH, // SDRAM High-byte Data Mask
|
| 87 |
+
output SDRAM_nWE, // SDRAM Write Enable
|
| 88 |
+
output SDRAM_nCAS, // SDRAM Column Address Strobe
|
| 89 |
+
output SDRAM_nRAS, // SDRAM Row Address Strobe
|
| 90 |
+
output SDRAM_nCS, // SDRAM Chip Select
|
| 91 |
+
output [1:0] SDRAM_BA, // SDRAM Bank Address
|
| 92 |
+
output SDRAM_CKE, // SDRAM Clock Enable
|
| 93 |
+
// SPI interface to arm io controller
|
| 94 |
+
inout SPI_DO,
|
| 95 |
+
input SPI_DI,
|
| 96 |
+
input SPI_SCK,
|
| 97 |
+
input SPI_SS2,
|
| 98 |
+
input SPI_SS3,
|
| 99 |
+
input SPI_SS4,
|
| 100 |
+
input CONF_DATA0,
|
| 101 |
+
// QSPI interface to ARM
|
| 102 |
+
input QCSn,
|
| 103 |
+
input QSCK,
|
| 104 |
+
input [3:0] QDAT,
|
| 105 |
+
// SDRAM interface for rotation
|
| 106 |
+
inout [15:0] sd_data,
|
| 107 |
+
output [12:0] sd_addr,
|
| 108 |
+
output [1:0] sd_dqm,
|
| 109 |
+
output [1:0] sd_ba,
|
| 110 |
+
output sd_cs,
|
| 111 |
+
output sd_we,
|
| 112 |
+
output sd_ras,
|
| 113 |
+
output sd_cas,
|
| 114 |
+
output sd_cke,
|
| 115 |
+
// Buttons for MC2(+)
|
| 116 |
+
input [ 3:0] BUTTON_n,
|
| 117 |
+
// PS2 are input pins for Neptuno
|
| 118 |
+
// and outputs for MiST
|
| 119 |
+
inout ps2_clk,
|
| 120 |
+
inout ps2_dout,
|
| 121 |
+
// Joystick
|
| 122 |
+
input [5:0] joy1_bus, joy2_bus,
|
| 123 |
+
output JOY_SELECT,
|
| 124 |
+
// ROM load from SPI
|
| 125 |
+
output [25:0] ioctl_addr,
|
| 126 |
+
output [ 7:0] ioctl_dout,
|
| 127 |
+
output ioctl_wr,
|
| 128 |
+
input [ 7:0] ioctl_din,
|
| 129 |
+
output ioctl_ram,
|
| 130 |
+
input dwnld_busy,
|
| 131 |
+
output ioctl_rom,
|
| 132 |
+
output ioctl_cart,
|
| 133 |
+
|
| 134 |
+
//////////// board
|
| 135 |
+
output rst, // synchronous reset
|
| 136 |
+
output rst_n, // asynchronous reset
|
| 137 |
+
output game_rst,
|
| 138 |
+
output game_rst_n,
|
| 139 |
+
// reset forcing signals:
|
| 140 |
+
input rst_req,
|
| 141 |
+
// Sound
|
| 142 |
+
input [15:0] snd_left, snd_right,
|
| 143 |
+
input snd_sample,
|
| 144 |
+
input snd_peak,
|
| 145 |
+
output [ 5:0] snd_en,
|
| 146 |
+
input [ 5:0] snd_vu,
|
| 147 |
+
output [ 7:0] snd_vol,
|
| 148 |
+
output AUDIO_L,
|
| 149 |
+
output AUDIO_R,
|
| 150 |
+
output I2S_BCK,
|
| 151 |
+
output I2S_LRCK,
|
| 152 |
+
output I2S_DATA,
|
| 153 |
+
output SPDIF,
|
| 154 |
+
|
| 155 |
+
// joystick
|
| 156 |
+
output [9:0] game_joystick1, game_joystick2, game_joystick3, game_joystick4,
|
| 157 |
+
output [3:0] game_coin, game_start,
|
| 158 |
+
output [1:0] dial_x, dial_y,
|
| 159 |
+
output game_service,
|
| 160 |
+
output game_tilt,
|
| 161 |
+
output [15:0] joyana_l1, joyana_r1, joyana_l2, joyana_r2, joyana_l3, joyana_r3, joyana_l4, joyana_r4,
|
| 162 |
+
// Paddle
|
| 163 |
+
output [ 7:0] paddle_1, paddle_2, paddle_3, paddle_4,
|
| 164 |
+
|
| 165 |
+
// Mouse
|
| 166 |
+
output [15:0] mouse_1p, mouse_2p,
|
| 167 |
+
output [ 1:0] mouse_strobe,
|
| 168 |
+
|
| 169 |
+
// Lightguns
|
| 170 |
+
output [ 8:0] gun_1p_x, gun_1p_y, gun_2p_x, gun_2p_y,
|
| 171 |
+
|
| 172 |
+
// DIP and OSD settings
|
| 173 |
+
output dip_test,
|
| 174 |
+
// non standard:
|
| 175 |
+
output dip_pause,
|
| 176 |
+
inout dip_flip, // A change in dip_flip implies a reset
|
| 177 |
+
output [ 1:0] dip_fxlevel,
|
| 178 |
+
// Debug
|
| 179 |
+
output LED,
|
| 180 |
+
output [ 7:0] st_addr,
|
| 181 |
+
input [ 7:0] st_dout,
|
| 182 |
+
output [ 3:0] gfx_en,
|
| 183 |
+
output [ 7:0] debug_bus,
|
| 184 |
+
input [ 7:0] debug_view
|
| 185 |
+
);
|
| 186 |
+
|
| 187 |
+
// control
|
| 188 |
+
wire [31:0] joystick1, joystick2, joystick3, joystick4;
|
| 189 |
+
reg [63:0] board_status;
|
| 190 |
+
wire ps2_kbd_clk, ps2_kbd_data;
|
| 191 |
+
wire osd_shown;
|
| 192 |
+
|
| 193 |
+
wire [7:0] game_vol=0; // per-game volume settings not available on ARC files
|
| 194 |
+
wire [6:0] core_mod;
|
| 195 |
+
wire [3:0] but_start, but_coin;
|
| 196 |
+
|
| 197 |
+
wire [ 1:0] rotate;
|
| 198 |
+
wire rot_osdonly;
|
| 199 |
+
wire ioctl_cheat, sdram_init;
|
| 200 |
+
|
| 201 |
+
wire [15:0] board_left, board_right;
|
| 202 |
+
|
| 203 |
+
wire [ 8:0] bd_mouse_dx, bd_mouse_dy;
|
| 204 |
+
wire bd_mouse_st, bd_mouse_idx;
|
| 205 |
+
wire [ 7:0] bd_mouse_f;
|
| 206 |
+
wire [ 7:0] ioctl_merged, mist_view;
|
| 207 |
+
wire [3*COLORW-1:0] base_rgb;
|
| 208 |
+
wire base_lhbl, base_lvbl, base_hs, base_vs;
|
| 209 |
+
|
| 210 |
+
assign paddle_3 = 0;
|
| 211 |
+
assign paddle_4 = 0;
|
| 212 |
+
assign dipsw = `ifdef JTFRAME_SIM_DIPS
|
| 213 |
+
`JTFRAME_SIM_DIPS `else
|
| 214 |
+
status[31+DIPBASE:DIPBASE] `endif;
|
| 215 |
+
assign ioctl_cart = 0; // not supported for now
|
| 216 |
+
|
| 217 |
+
always @* begin
|
| 218 |
+
board_status = { {64-DIPBASE{1'b0}}, status[DIPBASE-1:0] };
|
| 219 |
+
// bits 7:6 are also used for FX Volume, so cannot use both JTFRAME_SPINNER
|
| 220 |
+
// and JTFRAME_OSD_VOL together
|
| 221 |
+
board_status[33:32] = status[7:6];
|
| 222 |
+
end
|
| 223 |
+
|
| 224 |
+
jtframe_mist_base #(
|
| 225 |
+
.SIGNED_SND ( SIGNED_SND ),
|
| 226 |
+
.COLORW ( COLORW ),
|
| 227 |
+
.VGA_DW ( VGA_DW ),
|
| 228 |
+
.QSPI ( QSPI ),
|
| 229 |
+
.HDMI ( HDMI )
|
| 230 |
+
) u_base(
|
| 231 |
+
.rst ( rst ),
|
| 232 |
+
.sdram_init ( sdram_init ),
|
| 233 |
+
.clk_sys ( clk_sys ),
|
| 234 |
+
.clk_rom ( clk_rom ),
|
| 235 |
+
.core_mod ( core_mod ),
|
| 236 |
+
.osd_shown ( osd_shown ),
|
| 237 |
+
// Base video
|
| 238 |
+
.osd_rotate ( rot_osdonly ? rotate : 2'b00 ),
|
| 239 |
+
.rotation ( (rot_osdonly | ~rotate[0]) ? 2'b00 : {rotate[1], ~rotate[1]} ),
|
| 240 |
+
.game_rgb ( base_rgb ),
|
| 241 |
+
.game_lhbl ( base_lhbl ),
|
| 242 |
+
.game_lvbl ( base_lvbl ),
|
| 243 |
+
.game_hs ( base_hs ),
|
| 244 |
+
.game_vs ( base_vs ),
|
| 245 |
+
.pxl_cen ( pxl_cen ),
|
| 246 |
+
.pxl2_cen ( pxl2_cen ),
|
| 247 |
+
// MiST VGA pins (includes OSD)
|
| 248 |
+
.VIDEO_R ( VGA_R ),
|
| 249 |
+
.VIDEO_G ( VGA_G ),
|
| 250 |
+
.VIDEO_B ( VGA_B ),
|
| 251 |
+
.VIDEO_HS ( VGA_HS ),
|
| 252 |
+
.VIDEO_VS ( VGA_VS ),
|
| 253 |
+
// HDMI pins
|
| 254 |
+
.HDMI_R ( HDMI_R ),
|
| 255 |
+
.HDMI_G ( HDMI_G ),
|
| 256 |
+
.HDMI_B ( HDMI_B ),
|
| 257 |
+
.HDMI_HS ( HDMI_HS ),
|
| 258 |
+
.HDMI_VS ( HDMI_VS ),
|
| 259 |
+
.HDMI_DE ( HDMI_DE ),
|
| 260 |
+
.HDMI_SDA ( HDMI_SDA ),
|
| 261 |
+
.HDMI_SCL ( HDMI_SCL ),
|
| 262 |
+
// SPI interface to arm io controller
|
| 263 |
+
.SPI_DO ( SPI_DO ),
|
| 264 |
+
.SPI_DI ( SPI_DI ),
|
| 265 |
+
.SPI_SCK ( SPI_SCK ),
|
| 266 |
+
.SPI_SS2 ( SPI_SS2 ),
|
| 267 |
+
`ifndef NEPTUNO
|
| 268 |
+
.SPI_SS3 ( SPI_SS3 ),
|
| 269 |
+
.SPI_SS4 ( SPI_SS4 ),
|
| 270 |
+
`else
|
| 271 |
+
.SPI_SS3 ( SPI_SS2 ), // SS2 reused on NeptUNO for OSD
|
| 272 |
+
.SPI_SS4 ( ),
|
| 273 |
+
`endif
|
| 274 |
+
.CONF_DATA0 ( CONF_DATA0 ),
|
| 275 |
+
.QCSn ( QCSn ),
|
| 276 |
+
.QSCK ( QSCK ),
|
| 277 |
+
.QDAT ( QDAT ),
|
| 278 |
+
// RAM interface for rotation
|
| 279 |
+
.sd_data ( sd_data ),
|
| 280 |
+
.sd_addr ( sd_addr ),
|
| 281 |
+
.sd_dqm ( sd_dqm ),
|
| 282 |
+
.sd_ba ( sd_ba ),
|
| 283 |
+
.sd_cs ( sd_cs ),
|
| 284 |
+
.sd_we ( sd_we ),
|
| 285 |
+
.sd_ras ( sd_ras ),
|
| 286 |
+
.sd_cas ( sd_cas ),
|
| 287 |
+
.sd_cke ( sd_cke ),
|
| 288 |
+
// control
|
| 289 |
+
.status ( status ),
|
| 290 |
+
.joystick1 ( joystick1 ),
|
| 291 |
+
.joystick2 ( joystick2 ),
|
| 292 |
+
.joystick3 ( joystick3 ),
|
| 293 |
+
.joystick4 ( joystick4 ),
|
| 294 |
+
.but_start ( but_start ),
|
| 295 |
+
.but_coin ( but_coin ),
|
| 296 |
+
// Analog joystick
|
| 297 |
+
.joyana_l1 ( joyana_l1 ),
|
| 298 |
+
.joyana_r1 ( joyana_r1 ),
|
| 299 |
+
.joyana_l2 ( joyana_l2 ),
|
| 300 |
+
.joyana_r2 ( joyana_r2 ),
|
| 301 |
+
.joyana_l3 ( joyana_l3 ),
|
| 302 |
+
.joyana_r3 ( joyana_r3 ),
|
| 303 |
+
.joyana_l4 ( joyana_l4 ),
|
| 304 |
+
.joyana_r4 ( joyana_r4 ),
|
| 305 |
+
// Keyboard
|
| 306 |
+
.ps2_kbd_clk ( ps2_clk ),
|
| 307 |
+
.ps2_kbd_data ( ps2_dout ),
|
| 308 |
+
// Direct joystick connection (Neptuno / MC)
|
| 309 |
+
.joy1_bus ( joy1_bus ),
|
| 310 |
+
.joy2_bus ( joy2_bus ),
|
| 311 |
+
.JOY_SELECT ( JOY_SELECT ),
|
| 312 |
+
// Mouse
|
| 313 |
+
.mouse_st ( bd_mouse_st ),
|
| 314 |
+
.mouse_dx ( bd_mouse_dx ),
|
| 315 |
+
.mouse_dy ( bd_mouse_dy ),
|
| 316 |
+
.mouse_idx ( bd_mouse_idx ),
|
| 317 |
+
.mouse_f ( bd_mouse_f ),
|
| 318 |
+
// MC2(+) buttons
|
| 319 |
+
.BUTTON_n ( BUTTON_n ),
|
| 320 |
+
// audio
|
| 321 |
+
.clk_dac ( clk_sys ),
|
| 322 |
+
.snd_left ( board_left ),
|
| 323 |
+
.snd_right ( board_right ),
|
| 324 |
+
.snd_pwm_left ( AUDIO_L ),
|
| 325 |
+
.snd_pwm_right ( AUDIO_R ),
|
| 326 |
+
.I2S_BCK ( I2S_BCK ),
|
| 327 |
+
.I2S_LRCK ( I2S_LRCK ),
|
| 328 |
+
.I2S_DATA ( I2S_DATA ),
|
| 329 |
+
.SPDIF ( SPDIF ),
|
| 330 |
+
|
| 331 |
+
// ROM load from SPI
|
| 332 |
+
.ioctl_addr ( ioctl_addr ),
|
| 333 |
+
.ioctl_dout ( ioctl_dout ),
|
| 334 |
+
.ioctl_din ( ioctl_merged ),
|
| 335 |
+
.ioctl_wr ( ioctl_wr ),
|
| 336 |
+
.ioctl_ram ( ioctl_ram ),
|
| 337 |
+
.ioctl_cheat ( ioctl_cheat ),
|
| 338 |
+
.ioctl_rom ( ioctl_rom ),
|
| 339 |
+
// Debug
|
| 340 |
+
.debug_bus ( debug_bus ),
|
| 341 |
+
.debug_view ( mist_view )
|
| 342 |
+
);
|
| 343 |
+
|
| 344 |
+
assign HDMI_PCLK = clk_pico;
|
| 345 |
+
|
| 346 |
+
jtframe_board #(
|
| 347 |
+
.BUTTONS ( BUTTONS ),
|
| 348 |
+
.GAME_INPUTS_ACTIVE_LOW( GAME_INPUTS_ACTIVE_LOW),
|
| 349 |
+
.COLORW ( COLORW ),
|
| 350 |
+
.VIDEO_WIDTH ( VIDEO_WIDTH ),
|
| 351 |
+
.VIDEO_HEIGHT ( VIDEO_HEIGHT ),
|
| 352 |
+
.SDRAMW ( SDRAMW ),
|
| 353 |
+
.MISTER ( 0 ),
|
| 354 |
+
.XOR_ROT ( XOR_ROT )
|
| 355 |
+
) u_board(
|
| 356 |
+
.rst ( rst ),
|
| 357 |
+
.rst_n ( rst_n ),
|
| 358 |
+
.game_rst ( game_rst ),
|
| 359 |
+
.game_rst_n ( game_rst_n ),
|
| 360 |
+
.rst_req ( rst_req ),
|
| 361 |
+
.sdram_init ( sdram_init ),
|
| 362 |
+
.pll_locked ( pll_locked ),
|
| 363 |
+
.ioctl_ram ( ioctl_ram ),
|
| 364 |
+
.ioctl_cart ( ioctl_cart ),
|
| 365 |
+
.dwnld_busy ( dwnld_busy ), // use busy signal from game module
|
| 366 |
+
|
| 367 |
+
.clk_sys ( clk_sys ),
|
| 368 |
+
.clk_rom ( clk_rom ),
|
| 369 |
+
.clk_pico ( clk_pico ),
|
| 370 |
+
.game_vol ( game_vol ),
|
| 371 |
+
.core_mod ( core_mod ),
|
| 372 |
+
.vertical ( ),
|
| 373 |
+
.black_frame ( ),
|
| 374 |
+
// Sound
|
| 375 |
+
.snd_lin ( snd_left ),
|
| 376 |
+
.snd_rin ( snd_right ),
|
| 377 |
+
.snd_lout ( board_left ),
|
| 378 |
+
.snd_rout ( board_right ),
|
| 379 |
+
.snd_sample ( snd_sample ),
|
| 380 |
+
.snd_en ( snd_en ),
|
| 381 |
+
.snd_vu ( snd_vu ),
|
| 382 |
+
.snd_vol ( snd_vol ),
|
| 383 |
+
.snd_peak ( snd_peak ),
|
| 384 |
+
// joystick
|
| 385 |
+
.ps2_kbd_clk ( ps2_clk ),
|
| 386 |
+
.ps2_kbd_data ( ps2_dout ),
|
| 387 |
+
.board_joystick1( joystick1[15:0] ),
|
| 388 |
+
.board_joystick2( joystick2[15:0] ),
|
| 389 |
+
.board_joystick3( joystick3[15:0] ),
|
| 390 |
+
.board_joystick4( joystick4[15:0] ),
|
| 391 |
+
.joyana_l1 ( joyana_l1 ),
|
| 392 |
+
.joyana_r1 ( joyana_r1 ),
|
| 393 |
+
.joyana_l2 ( joyana_l2 ),
|
| 394 |
+
.joyana_r2 ( joyana_r2 ),
|
| 395 |
+
.board_start ( but_start ),
|
| 396 |
+
.board_coin ( but_coin ),
|
| 397 |
+
.game_joystick1 ( game_joystick1 ),
|
| 398 |
+
.game_joystick2 ( game_joystick2 ),
|
| 399 |
+
.game_joystick3 ( game_joystick3 ),
|
| 400 |
+
.game_joystick4 ( game_joystick4 ),
|
| 401 |
+
.game_coin ( game_coin ),
|
| 402 |
+
.game_start ( game_start ),
|
| 403 |
+
.game_service ( game_service ),
|
| 404 |
+
.game_tilt ( game_tilt ),
|
| 405 |
+
.dial_x ( dial_x ),
|
| 406 |
+
.dial_y ( dial_y ),
|
| 407 |
+
.spinner_1 ( 9'd0 ),
|
| 408 |
+
.spinner_2 ( 9'd0 ),
|
| 409 |
+
// Mouse & paddle
|
| 410 |
+
.bd_mouse_dx ( bd_mouse_dx ),
|
| 411 |
+
.bd_mouse_dy ( bd_mouse_dy ),
|
| 412 |
+
.bd_mouse_st ( bd_mouse_st ),
|
| 413 |
+
.bd_mouse_f ( bd_mouse_f ),
|
| 414 |
+
.bd_mouse_idx ( bd_mouse_idx ),
|
| 415 |
+
|
| 416 |
+
.board_paddle_1 ( 8'd0 ),
|
| 417 |
+
.board_paddle_2 ( 8'd0 ),
|
| 418 |
+
.game_paddle_1 ( paddle_1 ),
|
| 419 |
+
.game_paddle_2 ( paddle_2 ),
|
| 420 |
+
.mouse_1p ( mouse_1p ),
|
| 421 |
+
.mouse_2p ( mouse_2p ),
|
| 422 |
+
.mouse_strobe ( mouse_strobe ),
|
| 423 |
+
// Lightguns
|
| 424 |
+
.gun_1p_x ( gun_1p_x ),
|
| 425 |
+
.gun_1p_y ( gun_1p_y ),
|
| 426 |
+
.gun_2p_x ( gun_2p_x ),
|
| 427 |
+
.gun_2p_y ( gun_2p_y ),
|
| 428 |
+
.lightgun_en ( ),
|
| 429 |
+
// DIP and OSD settings
|
| 430 |
+
.status ( board_status ),
|
| 431 |
+
.dipsw ( dipsw[23:0] ),
|
| 432 |
+
.dip_test ( dip_test ),
|
| 433 |
+
.dip_pause ( dip_pause ),
|
| 434 |
+
.dip_flip ( dip_flip ),
|
| 435 |
+
.dip_fxlevel ( dip_fxlevel ),
|
| 436 |
+
.timestamp ( 32'd0 ), // MiST doesn't -normally- have a RTC
|
| 437 |
+
// screen
|
| 438 |
+
.rotate ( rotate ),
|
| 439 |
+
.rot_osdonly ( rot_osdonly ),
|
| 440 |
+
// LED
|
| 441 |
+
.osd_shown ( 1'b0 ), // osd_shown would pause the game
|
| 442 |
+
.led ( LED ),
|
| 443 |
+
// UART
|
| 444 |
+
.uart_rx ( uart_rx ),
|
| 445 |
+
.uart_tx ( uart_tx ),
|
| 446 |
+
// SDRAM interface
|
| 447 |
+
// Bank 0: allows R/W
|
| 448 |
+
.ba0_addr ( ba0_addr ),
|
| 449 |
+
.ba1_addr ( ba1_addr ),
|
| 450 |
+
.ba2_addr ( ba2_addr ),
|
| 451 |
+
.ba3_addr ( ba3_addr ),
|
| 452 |
+
.ba_rd ( ba_rd ),
|
| 453 |
+
.ba_wr ( ba_wr ),
|
| 454 |
+
.ba_dst ( ba_dst ),
|
| 455 |
+
.ba_dok ( ba_dok ),
|
| 456 |
+
.ba_rdy ( ba_rdy ),
|
| 457 |
+
.ba_ack ( ba_ack ),
|
| 458 |
+
.ba0_din ( ba0_din ),
|
| 459 |
+
.ba0_dsn ( ba0_dsn ),
|
| 460 |
+
.ba1_din ( ba1_din ),
|
| 461 |
+
.ba1_dsn ( ba1_dsn ),
|
| 462 |
+
.ba2_din ( ba2_din ),
|
| 463 |
+
.ba2_dsn ( ba2_dsn ),
|
| 464 |
+
.ba3_din ( ba3_din ),
|
| 465 |
+
.ba3_dsn ( ba3_dsn ),
|
| 466 |
+
|
| 467 |
+
// ROM-load interface
|
| 468 |
+
.prog_addr ( prog_addr ),
|
| 469 |
+
.prog_ba ( prog_ba ),
|
| 470 |
+
.prog_rd ( prog_rd ),
|
| 471 |
+
.prog_we ( prog_we ),
|
| 472 |
+
.prog_data ( prog_data ),
|
| 473 |
+
.prog_dsn ( prog_mask ),
|
| 474 |
+
.prog_rdy ( prog_rdy ),
|
| 475 |
+
.prog_dst ( prog_dst ),
|
| 476 |
+
.prog_dok ( prog_dok ),
|
| 477 |
+
.prog_ack ( prog_ack ),
|
| 478 |
+
// SDRAM interface
|
| 479 |
+
.SDRAM_DQ ( SDRAM_DQ ),
|
| 480 |
+
.SDRAM_A ( SDRAM_A ),
|
| 481 |
+
.SDRAM_DQML ( SDRAM_DQML ),
|
| 482 |
+
.SDRAM_DQMH ( SDRAM_DQMH ),
|
| 483 |
+
.SDRAM_nWE ( SDRAM_nWE ),
|
| 484 |
+
.SDRAM_nCAS ( SDRAM_nCAS ),
|
| 485 |
+
.SDRAM_nRAS ( SDRAM_nRAS ),
|
| 486 |
+
.SDRAM_nCS ( SDRAM_nCS ),
|
| 487 |
+
.SDRAM_BA ( SDRAM_BA ),
|
| 488 |
+
.SDRAM_CKE ( SDRAM_CKE ),
|
| 489 |
+
|
| 490 |
+
// Common signals
|
| 491 |
+
.sdram_dout ( sdram_dout ),
|
| 492 |
+
|
| 493 |
+
// Cheat!
|
| 494 |
+
.cheat ( status[63:32] ),
|
| 495 |
+
.prog_cheat ( ioctl_cheat ),
|
| 496 |
+
.prog_lock ( 1'b0 ), // locking is not needed on MiST
|
| 497 |
+
.ioctl_wr ( ioctl_wr ),
|
| 498 |
+
.ioctl_dout ( ioctl_dout ),
|
| 499 |
+
.ioctl_addr ( ioctl_addr[12:0] ),
|
| 500 |
+
.st_addr ( st_addr ),
|
| 501 |
+
.st_dout ( st_dout ),
|
| 502 |
+
.target_info( mist_view ),
|
| 503 |
+
|
| 504 |
+
// input data recording
|
| 505 |
+
.ioctl_din ( ioctl_din ),
|
| 506 |
+
.ioctl_merged ( ioctl_merged ),
|
| 507 |
+
|
| 508 |
+
.osd_rotate ( rotate ),
|
| 509 |
+
// input video
|
| 510 |
+
.game_r ( game_r ),
|
| 511 |
+
.game_g ( game_g ),
|
| 512 |
+
.game_b ( game_b ),
|
| 513 |
+
.LHBL ( LHBL ),
|
| 514 |
+
.LVBL ( LVBL ),
|
| 515 |
+
.hs ( hs ),
|
| 516 |
+
.vs ( vs ),
|
| 517 |
+
.pxl_cen ( pxl_cen ),
|
| 518 |
+
.pxl2_cen ( pxl2_cen ),
|
| 519 |
+
// output video with OSD/debug information
|
| 520 |
+
.base_rgb ( base_rgb ),
|
| 521 |
+
.base_lhbl ( base_lhbl ),
|
| 522 |
+
.base_lvbl ( base_lvbl ),
|
| 523 |
+
.base_hs ( base_hs ),
|
| 524 |
+
.base_vs ( base_vs ),
|
| 525 |
+
// Debug
|
| 526 |
+
.gfx_en ( gfx_en ),
|
| 527 |
+
.debug_bus ( debug_bus ),
|
| 528 |
+
.debug_view ( debug_view ),
|
| 529 |
+
// Unused ports (MiSTer)
|
| 530 |
+
.hdmi_arx ( ),
|
| 531 |
+
.hdmi_ary ( )
|
| 532 |
+
);
|
| 533 |
+
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/* This file is part of JTFRAME.
|
| 2 |
+
JTFRAME program is free software: you can redistribute it and/or modify
|
| 3 |
+
it under the terms of the GNU General Public License as published by
|
| 4 |
+
the Free Software Foundation, either version 3 of the License, or
|
| 5 |
+
(at your option) any later version.
|
| 6 |
+
|
| 7 |
+
JTFRAME program is distributed in the hope that it will be useful,
|
| 8 |
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
| 9 |
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
| 10 |
+
GNU General Public License for more details.
|
| 11 |
+
|
| 12 |
+
You should have received a copy of the GNU General Public License
|
| 13 |
+
along with JTFRAME. If not, see <http://www.gnu.org/licenses/>.
|
| 14 |
+
|
| 15 |
+
Author: Jose Tejada Gomez. Twitter: @topapate
|
| 16 |
+
Version: 1.0
|
| 17 |
+
Date: 27-10-2017 */
|
| 18 |
+
|
| 19 |
+
module jtframe_mist_base #(parameter
|
| 20 |
+
SIGNED_SND = 1'b0,
|
| 21 |
+
COLORW = 4,
|
| 22 |
+
VIDEO_WIDTH = 384,
|
| 23 |
+
VGA_DW = 6,
|
| 24 |
+
QSPI = 1'b0,
|
| 25 |
+
HDMI = 1'b0
|
| 26 |
+
) (
|
| 27 |
+
input rst,
|
| 28 |
+
input clk_sys,
|
| 29 |
+
input clk_rom,
|
| 30 |
+
input sdram_init,
|
| 31 |
+
output osd_shown,
|
| 32 |
+
output [6:0] core_mod,
|
| 33 |
+
// Base video
|
| 34 |
+
input [1:0] osd_rotate,
|
| 35 |
+
input [1:0] rotation, // 0 - no rotation, 1 - clockwise, 2 - anticlockwise
|
| 36 |
+
input game_hs,
|
| 37 |
+
input game_vs,
|
| 38 |
+
input game_lhbl,
|
| 39 |
+
input game_lvbl,
|
| 40 |
+
input [3*COLORW-1:0] game_rgb,
|
| 41 |
+
input pxl_cen,
|
| 42 |
+
input pxl2_cen,
|
| 43 |
+
// Final video: VGA+OSD or base+OSD depending on configuration
|
| 44 |
+
output [VGA_DW-1:0] VIDEO_R,
|
| 45 |
+
output [VGA_DW-1:0] VIDEO_G,
|
| 46 |
+
output [VGA_DW-1:0] VIDEO_B,
|
| 47 |
+
output VIDEO_HS,
|
| 48 |
+
output VIDEO_VS,
|
| 49 |
+
// HDMI pins
|
| 50 |
+
output [7:0] HDMI_R,
|
| 51 |
+
output [7:0] HDMI_G,
|
| 52 |
+
output [7:0] HDMI_B,
|
| 53 |
+
output HDMI_HS,
|
| 54 |
+
output HDMI_VS,
|
| 55 |
+
output HDMI_DE,
|
| 56 |
+
inout HDMI_SDA,
|
| 57 |
+
inout HDMI_SCL,
|
| 58 |
+
// SPI interface to arm io controller
|
| 59 |
+
inout SPI_DO,
|
| 60 |
+
input SPI_DI,
|
| 61 |
+
input SPI_SCK,
|
| 62 |
+
input SPI_SS2,
|
| 63 |
+
input SPI_SS3, // OSD interface
|
| 64 |
+
input SPI_SS4,
|
| 65 |
+
input CONF_DATA0,
|
| 66 |
+
// QSPI interface to ARM
|
| 67 |
+
input QCSn,
|
| 68 |
+
input QSCK,
|
| 69 |
+
input [3:0] QDAT,
|
| 70 |
+
// SDRAM interface for rotation
|
| 71 |
+
inout [15:0] sd_data,
|
| 72 |
+
output [12:0] sd_addr,
|
| 73 |
+
output [1:0] sd_dqm,
|
| 74 |
+
output [1:0] sd_ba,
|
| 75 |
+
output sd_cs,
|
| 76 |
+
output sd_we,
|
| 77 |
+
output sd_ras,
|
| 78 |
+
output sd_cas,
|
| 79 |
+
output sd_cke,
|
| 80 |
+
// control
|
| 81 |
+
output [63:0] status,
|
| 82 |
+
output [31:0] joystick1,
|
| 83 |
+
output [31:0] joystick2,
|
| 84 |
+
output [31:0] joystick3,
|
| 85 |
+
output [31:0] joystick4,
|
| 86 |
+
output [15:0] joyana_l1,
|
| 87 |
+
output [15:0] joyana_r1,
|
| 88 |
+
output [15:0] joyana_l2,
|
| 89 |
+
output [15:0] joyana_r2,
|
| 90 |
+
output [15:0] joyana_l3,
|
| 91 |
+
output [15:0] joyana_r3,
|
| 92 |
+
output [15:0] joyana_l4,
|
| 93 |
+
output [15:0] joyana_r4,
|
| 94 |
+
|
| 95 |
+
output [ 8:0] mouse_dx,
|
| 96 |
+
output [ 8:0] mouse_dy,
|
| 97 |
+
output [ 7:0] mouse_f,
|
| 98 |
+
output mouse_st,
|
| 99 |
+
output mouse_idx,
|
| 100 |
+
|
| 101 |
+
output [ 3:0] but_coin, // buttons, active high
|
| 102 |
+
output [ 3:0] but_start,
|
| 103 |
+
// PS2 pins are outputs if NEPTUNO isn't defined
|
| 104 |
+
inout ps2_kbd_clk,
|
| 105 |
+
inout ps2_kbd_data,
|
| 106 |
+
// Sound
|
| 107 |
+
input clk_dac,
|
| 108 |
+
input [15:0] snd_left,
|
| 109 |
+
input [15:0] snd_right,
|
| 110 |
+
output snd_pwm_left,
|
| 111 |
+
output snd_pwm_right,
|
| 112 |
+
output I2S_BCK,
|
| 113 |
+
output I2S_LRCK,
|
| 114 |
+
output I2S_DATA,
|
| 115 |
+
output SPDIF,
|
| 116 |
+
|
| 117 |
+
// Direct joystick connection (Neptuno / MC)
|
| 118 |
+
input [5:0] joy1_bus,
|
| 119 |
+
input [5:0] joy2_bus,
|
| 120 |
+
output JOY_SELECT,
|
| 121 |
+
|
| 122 |
+
// Buttons for MC2(+)
|
| 123 |
+
input [ 3:0] BUTTON_n,
|
| 124 |
+
|
| 125 |
+
// ROM load from SPI
|
| 126 |
+
output [25:0] ioctl_addr,
|
| 127 |
+
output [ 7:0] ioctl_dout,
|
| 128 |
+
input [ 7:0] ioctl_din,
|
| 129 |
+
output ioctl_wr,
|
| 130 |
+
output ioctl_ram,
|
| 131 |
+
output ioctl_cheat,
|
| 132 |
+
output ioctl_rom,
|
| 133 |
+
// Debug
|
| 134 |
+
input [7:0]debug_bus,
|
| 135 |
+
output reg [7:0]debug_view
|
| 136 |
+
);
|
| 137 |
+
|
| 138 |
+
localparam [7:0] IDX_ROM = 8'h00,
|
| 139 |
+
IDX_CHEAT = 8'h10,
|
| 140 |
+
IDX_NVRAM = 8'hFF;
|
| 141 |
+
|
| 142 |
+
wire ypbpr, no_csync;
|
| 143 |
+
wire [7:0] ioctl_index;
|
| 144 |
+
wire ioctl_download, ioctl_upload;
|
| 145 |
+
|
| 146 |
+
// Scan-doubler video
|
| 147 |
+
wire [7:0] scan2x_r, scan2x_g, scan2x_b;
|
| 148 |
+
wire scan2x_hs, scan2x_vs, scan2x_de, scan2x_enb;
|
| 149 |
+
|
| 150 |
+
assign ioctl_rom = ioctl_index == IDX_ROM && ioctl_download;
|
| 151 |
+
assign ioctl_ram = (ioctl_index == IDX_NVRAM && ioctl_download) || ioctl_upload;
|
| 152 |
+
assign ioctl_cheat = ioctl_index == IDX_CHEAT && ioctl_download;
|
| 153 |
+
|
| 154 |
+
// unsupported by user_io
|
| 155 |
+
assign joyana_l3 = 0;
|
| 156 |
+
assign joyana_r3 = 0;
|
| 157 |
+
assign joyana_l4 = 0;
|
| 158 |
+
assign joyana_r4 = 0;
|
| 159 |
+
|
| 160 |
+
|
| 161 |
+
always @(posedge clk_sys) begin
|
| 162 |
+
case(debug_bus[3:0])
|
| 163 |
+
0: debug_view <= status[0*8+:8];
|
| 164 |
+
1: debug_view <= status[1*8+:8];
|
| 165 |
+
2: debug_view <= status[2*8+:8];
|
| 166 |
+
3: debug_view <= status[3*8+:8];
|
| 167 |
+
4: debug_view <= status[4*8+:8];
|
| 168 |
+
5: debug_view <= status[5*8+:8];
|
| 169 |
+
6: debug_view <= status[6*8+:8];
|
| 170 |
+
7: debug_view <= status[7*8+:8];
|
| 171 |
+
default: debug_view <= { osd_shown, 1'b0, osd_rotate, 1'b0, no_csync, ypbpr, scan2x_enb };
|
| 172 |
+
endcase
|
| 173 |
+
end
|
| 174 |
+
|
| 175 |
+
`ifndef SIMULATION
|
| 176 |
+
`ifndef NOSOUND
|
| 177 |
+
wire cen_dac;
|
| 178 |
+
reg [3:0] cen_dac_sr;
|
| 179 |
+
|
| 180 |
+
assign cen_dac = cen_dac_sr[0];
|
| 181 |
+
always @(posedge clk_dac, posedge rst) begin
|
| 182 |
+
if( rst )
|
| 183 |
+
cen_dac_sr <= 4'b100;
|
| 184 |
+
else begin
|
| 185 |
+
cen_dac_sr <= { cen_dac_sr[2:0], cen_dac_sr[3] };
|
| 186 |
+
end
|
| 187 |
+
end
|
| 188 |
+
|
| 189 |
+
function [19:0] snd_padded;
|
| 190 |
+
input [15:0] snd;
|
| 191 |
+
reg [15:0] snd_in;
|
| 192 |
+
begin
|
| 193 |
+
snd_in = {snd[15]^SIGNED_SND[0], snd[14:0]};
|
| 194 |
+
snd_padded = { 1'b0, snd_in, 3'd0 };
|
| 195 |
+
end
|
| 196 |
+
endfunction
|
| 197 |
+
|
| 198 |
+
hifi_1bit_dac u_dac_left
|
| 199 |
+
(
|
| 200 |
+
.reset ( rst ),
|
| 201 |
+
.clk ( clk_dac ),
|
| 202 |
+
.clk_ena ( cen_dac ),
|
| 203 |
+
.pcm_in ( snd_padded(snd_left) ),
|
| 204 |
+
.dac_out ( snd_pwm_left )
|
| 205 |
+
);
|
| 206 |
+
|
| 207 |
+
`ifdef JTFRAME_STEREO
|
| 208 |
+
hifi_1bit_dac u_dac_right
|
| 209 |
+
(
|
| 210 |
+
.reset ( rst ),
|
| 211 |
+
.clk ( clk_dac ),
|
| 212 |
+
.clk_ena ( cen_dac ),
|
| 213 |
+
.pcm_in ( snd_padded(snd_right)),
|
| 214 |
+
.dac_out ( snd_pwm_right )
|
| 215 |
+
);
|
| 216 |
+
`else
|
| 217 |
+
assign snd_pwm_right = snd_pwm_left;
|
| 218 |
+
`endif
|
| 219 |
+
`else // NOSOUND
|
| 220 |
+
assign snd_pwm_left = 0;
|
| 221 |
+
assign snd_pwm_right = 0;
|
| 222 |
+
`endif
|
| 223 |
+
`else // Simulation:
|
| 224 |
+
assign snd_pwm_left = 0;
|
| 225 |
+
assign snd_pwm_right = 0;
|
| 226 |
+
`endif
|
| 227 |
+
|
| 228 |
+
`ifndef SIMULATION
|
| 229 |
+
`ifndef NOSOUND
|
| 230 |
+
|
| 231 |
+
localparam [31:0] CLKRATE = `JTFRAME_MCLK;
|
| 232 |
+
|
| 233 |
+
wire [19:0] snd_padded_left = snd_padded(snd_left);
|
| 234 |
+
wire [19:0] snd_padded_right = snd_padded(snd_right);
|
| 235 |
+
|
| 236 |
+
i2s i2s(
|
| 237 |
+
.reset(1'b0),
|
| 238 |
+
.clk(clk_sys),
|
| 239 |
+
.clk_rate(CLKRATE),
|
| 240 |
+
|
| 241 |
+
.sclk(I2S_BCK),
|
| 242 |
+
.lrclk(I2S_LRCK),
|
| 243 |
+
.sdata(I2S_DATA),
|
| 244 |
+
|
| 245 |
+
.left_chan(snd_padded_left[19:4]),
|
| 246 |
+
.right_chan(snd_padded_right[19:4])
|
| 247 |
+
);
|
| 248 |
+
|
| 249 |
+
spdif spdif(
|
| 250 |
+
.clk_i(clk_sys),
|
| 251 |
+
.rst_i(1'b0),
|
| 252 |
+
.clk_rate_i(CLKRATE),
|
| 253 |
+
.spdif_o(SPDIF),
|
| 254 |
+
.sample_i({snd_padded_right[19:4], snd_padded_left[19:4]})
|
| 255 |
+
);
|
| 256 |
+
`else
|
| 257 |
+
assign I2S_DATA=0, SPDIF=0, I2S_BCK=0, I2S_LRCK=0;
|
| 258 |
+
`endif
|
| 259 |
+
`endif
|
| 260 |
+
|
| 261 |
+
`ifndef JTFRAME_MIST_DIRECT
|
| 262 |
+
`define JTFRAME_MIST_DIRECT 1'b1
|
| 263 |
+
`endif
|
| 264 |
+
|
| 265 |
+
`ifndef SIMULATION
|
| 266 |
+
wire [9:0] cfg_addr;
|
| 267 |
+
wire [7:0] cfg_dout;
|
| 268 |
+
|
| 269 |
+
jtframe_ram #(.SYNFILE("cfgstr.hex")) u_cfgstr(
|
| 270 |
+
.clk ( SPI_SCK ),
|
| 271 |
+
.cen ( 1'b1 ),
|
| 272 |
+
.data ( ),
|
| 273 |
+
.addr ( cfg_addr ),
|
| 274 |
+
.we ( 1'b0 ),
|
| 275 |
+
.q ( cfg_dout )
|
| 276 |
+
);
|
| 277 |
+
|
| 278 |
+
wire i2c_start;
|
| 279 |
+
wire i2c_read;
|
| 280 |
+
wire [6:0] i2c_addr;
|
| 281 |
+
wire [7:0] i2c_subaddr;
|
| 282 |
+
wire [7:0] i2c_dout;
|
| 283 |
+
wire [7:0] i2c_din;
|
| 284 |
+
wire i2c_ack;
|
| 285 |
+
wire i2c_end;
|
| 286 |
+
|
| 287 |
+
`ifndef NEPTUNO
|
| 288 |
+
wire [1:0] buttons;
|
| 289 |
+
assign but_coin = 4'd0;
|
| 290 |
+
assign but_start = 4'd0;
|
| 291 |
+
wire [63:0] user_io_status;
|
| 292 |
+
assign status = {user_io_status[63:1], user_io_status[0] | buttons[1]}; // status[0] | buttons[1] is reset
|
| 293 |
+
|
| 294 |
+
user_io #(.ROM_DIRECT_UPLOAD(`JTFRAME_MIST_DIRECT), .FEATURES(32'h0 /*| (QSPI << 2)*/ | (HDMI << 14))) u_userio(
|
| 295 |
+
.clk_sys ( clk_sys ),
|
| 296 |
+
|
| 297 |
+
// config string
|
| 298 |
+
.conf_str ( ),
|
| 299 |
+
.conf_addr ( cfg_addr ),
|
| 300 |
+
.conf_chr ( cfg_dout ),
|
| 301 |
+
|
| 302 |
+
.SPI_CLK ( SPI_SCK ),
|
| 303 |
+
.SPI_SS_IO ( CONF_DATA0),
|
| 304 |
+
.SPI_MISO ( SPI_DO ),
|
| 305 |
+
.SPI_MOSI ( SPI_DI ),
|
| 306 |
+
.joystick_0 ( joystick2 ),
|
| 307 |
+
.joystick_1 ( joystick1 ),
|
| 308 |
+
.joystick_2 ( joystick3 ),
|
| 309 |
+
.joystick_3 ( joystick4 ),
|
| 310 |
+
.buttons ( buttons ),
|
| 311 |
+
// Analog joysticks
|
| 312 |
+
.joystick_analog_0({joyana_r2[7:0], joyana_r2[15:8], joyana_l2}),
|
| 313 |
+
.joystick_analog_1({joyana_r1[7:0], joyana_r1[15:8], joyana_l1}),
|
| 314 |
+
|
| 315 |
+
.status ( user_io_status ),
|
| 316 |
+
.ypbpr ( ypbpr ),
|
| 317 |
+
.no_csync ( no_csync ),
|
| 318 |
+
.scandoubler_disable ( scan2x_enb ),
|
| 319 |
+
// keyboard
|
| 320 |
+
.ps2_kbd_clk ( ps2_kbd_clk ),
|
| 321 |
+
.ps2_kbd_data ( ps2_kbd_data ),
|
| 322 |
+
// Core variant
|
| 323 |
+
.core_mod ( core_mod ),
|
| 324 |
+
// i2c bridge
|
| 325 |
+
.i2c_start (i2c_start ),
|
| 326 |
+
.i2c_read (i2c_read ),
|
| 327 |
+
.i2c_addr (i2c_addr ),
|
| 328 |
+
.i2c_subaddr (i2c_subaddr),
|
| 329 |
+
.i2c_dout (i2c_dout ),
|
| 330 |
+
.i2c_din (i2c_din ),
|
| 331 |
+
.i2c_ack (i2c_ack ),
|
| 332 |
+
.i2c_end (i2c_end ),
|
| 333 |
+
// unused ports:
|
| 334 |
+
.serial_strobe ( 1'b0 ),
|
| 335 |
+
.serial_data ( 8'd0 ),
|
| 336 |
+
.sd_lba ( 32'd0 ),
|
| 337 |
+
.sd_rd ( 1'b0 ),
|
| 338 |
+
.sd_wr ( 1'b0 ),
|
| 339 |
+
.sd_conf ( 1'b0 ),
|
| 340 |
+
.sd_sdhc ( 1'b0 ),
|
| 341 |
+
.sd_din ( 8'd0 ),
|
| 342 |
+
.mouse_x ( mouse_dx ),
|
| 343 |
+
.mouse_y ( mouse_dy ),
|
| 344 |
+
.mouse_z ( ),
|
| 345 |
+
.mouse_flags ( mouse_f ),
|
| 346 |
+
.mouse_strobe ( mouse_st ),
|
| 347 |
+
.mouse_idx ( mouse_idx )
|
| 348 |
+
);
|
| 349 |
+
`else
|
| 350 |
+
assign ypbpr = 0;
|
| 351 |
+
assign no_csync = 1;
|
| 352 |
+
`endif
|
| 353 |
+
// Simulation:
|
| 354 |
+
`else // these inputs are not used in simulation:
|
| 355 |
+
assign joystick1 = 32'd0;
|
| 356 |
+
assign joystick2 = 32'd0;
|
| 357 |
+
assign joystick3 = 32'd0;
|
| 358 |
+
assign joystick4 = 32'd0;
|
| 359 |
+
assign joyana_l1 = 0;
|
| 360 |
+
assign joyana_r1 = 0;
|
| 361 |
+
assign status = 64'd0;
|
| 362 |
+
assign but_coin = 0;
|
| 363 |
+
assign but_start = 0;
|
| 364 |
+
`ifndef SCANDOUBLER_DISABLE
|
| 365 |
+
`define SCANDOUBLER_DISABLE 1'b1
|
| 366 |
+
initial $display("INFO: Use -d SCANDOUBLER_DISABLE=0 if you want video output.");
|
| 367 |
+
`endif
|
| 368 |
+
initial $display("INFO:SCANDOUBLER_DISABLE=%d",`SCANDOUBLER_DISABLE);
|
| 369 |
+
assign scan2x_enb = `SCANDOUBLER_DISABLE;
|
| 370 |
+
assign ypbpr = 1'b0;
|
| 371 |
+
`endif
|
| 372 |
+
|
| 373 |
+
`ifndef NEPTUNO
|
| 374 |
+
data_io #(.ROM_DIRECT_UPLOAD(1'b1), .USE_QSPI(QSPI)) u_datain (
|
| 375 |
+
.clkref_n ( 1'b0 ),
|
| 376 |
+
.SPI_SCK ( SPI_SCK ),
|
| 377 |
+
.SPI_SS2 ( SPI_SS2 ),
|
| 378 |
+
.SPI_SS4 ( SPI_SS4 ),
|
| 379 |
+
.SPI_DI ( SPI_DI ),
|
| 380 |
+
.SPI_DO ( SPI_DO ),
|
| 381 |
+
|
| 382 |
+
.QCSn ( QCSn ),
|
| 383 |
+
.QSCK ( QSCK ),
|
| 384 |
+
.QDAT ( QDAT ),
|
| 385 |
+
|
| 386 |
+
.clk_sys ( clk_rom ),
|
| 387 |
+
.ioctl_download ( ioctl_download ),
|
| 388 |
+
.ioctl_addr ( ioctl_addr ),
|
| 389 |
+
.ioctl_dout ( ioctl_dout ),
|
| 390 |
+
.ioctl_din ( ioctl_din ),
|
| 391 |
+
.ioctl_wr ( ioctl_wr ),
|
| 392 |
+
.ioctl_index ( ioctl_index ),
|
| 393 |
+
.ioctl_upload ( ioctl_upload ),
|
| 394 |
+
// Unused:
|
| 395 |
+
.ioctl_fileext ( ),
|
| 396 |
+
.ioctl_filesize ( ),
|
| 397 |
+
|
| 398 |
+
.hdd_clk ( 1'b0 ),
|
| 399 |
+
.hdd_cmd_req ( ),
|
| 400 |
+
.hdd_cdda_req ( ),
|
| 401 |
+
.hdd_dat_req ( ),
|
| 402 |
+
.hdd_cdda_wr ( ),
|
| 403 |
+
.hdd_status_wr ( ),
|
| 404 |
+
.hdd_addr ( ),
|
| 405 |
+
.hdd_wr ( ),
|
| 406 |
+
|
| 407 |
+
.hdd_data_out ( ),
|
| 408 |
+
.hdd_data_in ( ),
|
| 409 |
+
.hdd_data_rd ( ),
|
| 410 |
+
.hdd_data_wr ( ),
|
| 411 |
+
|
| 412 |
+
.hdd0_ena ( ),
|
| 413 |
+
.hdd1_ena ( )
|
| 414 |
+
);
|
| 415 |
+
|
| 416 |
+
assign JOY_SELECT=0;
|
| 417 |
+
`else
|
| 418 |
+
// Neptuno
|
| 419 |
+
wire [8:0] nept_controls;
|
| 420 |
+
assign but_coin = nept_controls[7:4];
|
| 421 |
+
assign but_start = nept_controls[3:0];
|
| 422 |
+
// Mouse not supported
|
| 423 |
+
assign mouse_st = 0;
|
| 424 |
+
assign mouse_dx = 0;
|
| 425 |
+
assign mouse_dy = 0;
|
| 426 |
+
assign mouse_idx = 0;
|
| 427 |
+
assign mouse_f = 0;
|
| 428 |
+
|
| 429 |
+
jtframe_neptuno_io u_neptuno_io(
|
| 430 |
+
.sdram_init ( sdram_init ),
|
| 431 |
+
.clk_sys ( clk_sys ),
|
| 432 |
+
.clk_rom ( clk_rom ),
|
| 433 |
+
.hs ( game_hs ),
|
| 434 |
+
|
| 435 |
+
.SPI_SCK ( SPI_SCK ),
|
| 436 |
+
.SPI_SS2 ( SPI_SS2 ),
|
| 437 |
+
.SPI_DI ( SPI_DI ),
|
| 438 |
+
.SPI_DO ( SPI_DO ),
|
| 439 |
+
|
| 440 |
+
// Config string
|
| 441 |
+
.cfg_addr ( cfg_addr ),
|
| 442 |
+
.cfg_dout ( cfg_dout ),
|
| 443 |
+
|
| 444 |
+
.ioctl_download ( ioctl_download),
|
| 445 |
+
.ioctl_index ( ioctl_index ),
|
| 446 |
+
.ioctl_wr ( ioctl_wr ),
|
| 447 |
+
.ioctl_addr ( ioctl_addr ),
|
| 448 |
+
.ioctl_dout ( ioctl_dout ),
|
| 449 |
+
|
| 450 |
+
.core_mod ( core_mod ),
|
| 451 |
+
.status ( status ),
|
| 452 |
+
.scan2x_enb ( scan2x_enb ),
|
| 453 |
+
|
| 454 |
+
// DB9 Joysticks
|
| 455 |
+
.joy1_bus ( joy1_bus ),
|
| 456 |
+
.joy2_bus ( joy2_bus ),
|
| 457 |
+
.JOY_SELECT ( JOY_SELECT ),
|
| 458 |
+
|
| 459 |
+
.BUTTON_n ( BUTTON_n ),
|
| 460 |
+
|
| 461 |
+
// keyboard
|
| 462 |
+
.ps2_kbd_clk ( ps2_kbd_clk ),
|
| 463 |
+
.ps2_kbd_data ( ps2_kbd_data ),
|
| 464 |
+
|
| 465 |
+
.joystick1 (joystick1[11:0]),
|
| 466 |
+
.joystick2 (joystick2[11:0]),
|
| 467 |
+
.controls ( nept_controls )
|
| 468 |
+
);
|
| 469 |
+
|
| 470 |
+
assign joystick1[31:12] = 0;
|
| 471 |
+
assign joystick2[31:12] = 0;
|
| 472 |
+
assign joystick3 = 0;
|
| 473 |
+
assign joystick4 = 0;
|
| 474 |
+
assign joyana_l1 = 0;
|
| 475 |
+
assign joyana_r1 = 0;
|
| 476 |
+
assign ioctl_upload = 0;
|
| 477 |
+
`endif
|
| 478 |
+
|
| 479 |
+
reg [1:0] scanlines;
|
| 480 |
+
reg bw_en, blend_en;
|
| 481 |
+
|
| 482 |
+
always @(*) begin
|
| 483 |
+
case( status[4:3] )
|
| 484 |
+
2'd0: { scanlines, bw_en, blend_en } = { 2'd0, 2'd0 }; // pass thru
|
| 485 |
+
2'd1: { scanlines, bw_en, blend_en } = { 2'd0, 2'd1 }; // no scanlines, linear interpolation
|
| 486 |
+
2'd2: { scanlines, bw_en, blend_en } = { 2'd0, 2'd3 }; // analogue
|
| 487 |
+
2'd3: { scanlines, bw_en, blend_en } = { 2'd1, 2'd3 }; // analogue + scan lines
|
| 488 |
+
endcase // status[4:3]
|
| 489 |
+
`ifdef JTFRAME_FEEDTHRU
|
| 490 |
+
{ scanlines, bw_en, blend_en } = { 3'd0, 2'd0 }; `endif
|
| 491 |
+
end
|
| 492 |
+
|
| 493 |
+
jtframe_mist_video #(
|
| 494 |
+
.COLORW ( COLORW ),
|
| 495 |
+
.VGA_DW ( VGA_DW ),
|
| 496 |
+
.VIDEO_WIDTH( VIDEO_WIDTH ))
|
| 497 |
+
u_video(
|
| 498 |
+
.rst ( rst ),
|
| 499 |
+
.clk ( clk_sys ),
|
| 500 |
+
// base video
|
| 501 |
+
.pxl_cen ( pxl_cen ),
|
| 502 |
+
.pxl2_cen ( pxl2_cen ),
|
| 503 |
+
.game_hs ( game_hs ),
|
| 504 |
+
.game_vs ( game_vs ),
|
| 505 |
+
.game_lvbl ( game_lvbl ),
|
| 506 |
+
.game_lhbl ( game_lhbl ),
|
| 507 |
+
.game_rgb ( game_rgb ),
|
| 508 |
+
// SPI for OSD contents
|
| 509 |
+
.osd_di ( SPI_DI ),
|
| 510 |
+
.osd_sck ( SPI_SCK ),
|
| 511 |
+
.osd_ss3 ( SPI_SS3 ),
|
| 512 |
+
.osd_rotate ( osd_rotate ),
|
| 513 |
+
.osd_shown ( osd_shown ),
|
| 514 |
+
// low pass filter for video
|
| 515 |
+
.bw_en ( bw_en ),
|
| 516 |
+
.blend_en ( blend_en ),
|
| 517 |
+
.scanlines ( scanlines ),
|
| 518 |
+
.rotation ( rotation ),
|
| 519 |
+
// video signal type
|
| 520 |
+
.ypbpr ( ypbpr ),
|
| 521 |
+
.no_csync ( no_csync ),
|
| 522 |
+
.scan2x_en ( ~scan2x_enb ), // scan doubler enable bar
|
| 523 |
+
.sog ( 1'b0 ),
|
| 524 |
+
.cvideo_en ( 1'b0 ),
|
| 525 |
+
.pal_en ( 1'b0 ),
|
| 526 |
+
// Scan-doubler video
|
| 527 |
+
.scan2x_r ( scan2x_r ),
|
| 528 |
+
.scan2x_g ( scan2x_g ),
|
| 529 |
+
.scan2x_b ( scan2x_b ),
|
| 530 |
+
.scan2x_hs ( scan2x_hs ),
|
| 531 |
+
.scan2x_vs ( scan2x_vs ),
|
| 532 |
+
.scan2x_de ( scan2x_de ),
|
| 533 |
+
.scan2x_HB ( ),
|
| 534 |
+
.scan2x_VB ( ),
|
| 535 |
+
// crt video
|
| 536 |
+
.video_hs ( VIDEO_HS ),
|
| 537 |
+
.video_vs ( VIDEO_VS ),
|
| 538 |
+
.video_de ( ),
|
| 539 |
+
.video_r ( VIDEO_R ),
|
| 540 |
+
.video_g ( VIDEO_G ),
|
| 541 |
+
.video_b ( VIDEO_B ),
|
| 542 |
+
.yc_vid ( ),
|
| 543 |
+
// RAM interface for rotation
|
| 544 |
+
.init ( sdram_init ),
|
| 545 |
+
.sd_data ( sd_data ),
|
| 546 |
+
.sd_addr ( sd_addr ),
|
| 547 |
+
.sd_dqm ( sd_dqm ),
|
| 548 |
+
.sd_ba ( sd_ba ),
|
| 549 |
+
.sd_cs ( sd_cs ),
|
| 550 |
+
.sd_we ( sd_we ),
|
| 551 |
+
.sd_ras ( sd_ras ),
|
| 552 |
+
.sd_cas ( sd_cas ),
|
| 553 |
+
.sd_cke ( sd_cke )
|
| 554 |
+
|
| 555 |
+
);
|
| 556 |
+
|
| 557 |
+
generate if (HDMI) begin
|
| 558 |
+
i2c_master #(96_000_000) i2c_master (
|
| 559 |
+
.CLK (clk_sys),
|
| 560 |
+
.I2C_START (i2c_start),
|
| 561 |
+
.I2C_READ (i2c_read),
|
| 562 |
+
.I2C_ADDR (i2c_addr),
|
| 563 |
+
.I2C_SUBADDR (i2c_subaddr),
|
| 564 |
+
.I2C_WDATA (i2c_dout),
|
| 565 |
+
.I2C_RDATA (i2c_din),
|
| 566 |
+
.I2C_END (i2c_end),
|
| 567 |
+
.I2C_ACK (i2c_ack),
|
| 568 |
+
|
| 569 |
+
//I2C bus
|
| 570 |
+
.I2C_SCL (HDMI_SCL),
|
| 571 |
+
.I2C_SDA (HDMI_SDA)
|
| 572 |
+
);
|
| 573 |
+
|
| 574 |
+
osd #(0,0,6'b01_11_01,8) hdmi_osd (
|
| 575 |
+
.clk_sys ( clk_sys ),
|
| 576 |
+
|
| 577 |
+
// spi for OSD
|
| 578 |
+
.SPI_DI ( SPI_DI ),
|
| 579 |
+
.SPI_SCK ( SPI_SCK ),
|
| 580 |
+
.SPI_SS3 ( SPI_SS3 ),
|
| 581 |
+
|
| 582 |
+
.rotate ( osd_rotate ),
|
| 583 |
+
|
| 584 |
+
.R_in ( scan2x_r[7:0]),
|
| 585 |
+
.G_in ( scan2x_g[7:0]),
|
| 586 |
+
.B_in ( scan2x_b[7:0]),
|
| 587 |
+
.DE ( scan2x_de ),
|
| 588 |
+
.HSync ( scan2x_hs ),
|
| 589 |
+
.VSync ( scan2x_vs ),
|
| 590 |
+
|
| 591 |
+
.R_out ( HDMI_R ),
|
| 592 |
+
.G_out ( HDMI_G ),
|
| 593 |
+
.B_out ( HDMI_B ),
|
| 594 |
+
.HSync_out ( HDMI_HS ),
|
| 595 |
+
.VSync_out ( HDMI_VS ),
|
| 596 |
+
.DE_out ( HDMI_DE ),
|
| 597 |
+
.osd_shown ( )
|
| 598 |
+
);
|
| 599 |
+
|
| 600 |
+
end else begin
|
| 601 |
+
assign HDMI_SCL = 1'bZ;
|
| 602 |
+
assign HDMI_SDA = 1'bZ;
|
| 603 |
+
assign HDMI_R = 8'd0;
|
| 604 |
+
assign HDMI_G = 8'd0;
|
| 605 |
+
assign HDMI_B = 8'd0;
|
| 606 |
+
assign HDMI_HS = 1'b0;
|
| 607 |
+
assign HDMI_VS = 1'b0;
|
| 608 |
+
assign HDMI_DE = 1'b0;
|
| 609 |
+
end
|
| 610 |
+
|
| 611 |
+
endgenerate
|
| 612 |
+
endmodule
|
snapshots/jotego_jtcores_pr1270/modules/jtframe/target/mist/hdl/jtframe_mist_clocks.v
ADDED
|
@@ -0,0 +1,119 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/* This file is part of JTFRAME.
|
| 2 |
+
JTFRAME program is free software: you can redistribute it and/or modify
|
| 3 |
+
it under the terms of the GNU General Public License as published by
|
| 4 |
+
the Free Software Foundation, either version 3 of the License, or
|
| 5 |
+
(at your option) any later version.
|
| 6 |
+
|
| 7 |
+
JTFRAME program is distributed in the hope that it will be useful,
|
| 8 |
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
| 9 |
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
| 10 |
+
GNU General Public License for more details.
|
| 11 |
+
|
| 12 |
+
You should have received a copy of the GNU General Public License
|
| 13 |
+
along with JTFRAME. If not, see <http://www.gnu.org/licenses/>.
|
| 14 |
+
|
| 15 |
+
Author: Jose Tejada Gomez. Twitter: @topapate
|
| 16 |
+
Version: 1.0
|
| 17 |
+
Date: 22-2-2019 */
|
| 18 |
+
|
| 19 |
+
module jtframe_mist_clocks(
|
| 20 |
+
input clk_ext, // 27MHz for MiST, 50MHz for Neptuno
|
| 21 |
+
|
| 22 |
+
// PLL outputs
|
| 23 |
+
output clk96,
|
| 24 |
+
output clk48,
|
| 25 |
+
output clk24,
|
| 26 |
+
output pll_locked,
|
| 27 |
+
|
| 28 |
+
// System clocks
|
| 29 |
+
output clk_sys,
|
| 30 |
+
output clk_rom,
|
| 31 |
+
output SDRAM_CLK,
|
| 32 |
+
|
| 33 |
+
// reset signals
|
| 34 |
+
input game_rst,
|
| 35 |
+
output rst96,
|
| 36 |
+
output rst48,
|
| 37 |
+
output rst24
|
| 38 |
+
);
|
| 39 |
+
|
| 40 |
+
`ifndef JTFRAME_PLL
|
| 41 |
+
`define JTFRAME_PLL jtframe_pll6000
|
| 42 |
+
`endif
|
| 43 |
+
|
| 44 |
+
// The PLL for 96MHz has a different phase shift for the SDRAM clock
|
| 45 |
+
// This phase is related to the SDRAM controller configuration set
|
| 46 |
+
// in jtframe_board.
|
| 47 |
+
`ifdef JTFRAME_SDRAM96
|
| 48 |
+
`define JTFRAME_GAMEPLL jtframe_pllgame96
|
| 49 |
+
`else
|
| 50 |
+
`define JTFRAME_GAMEPLL jtframe_pllgame
|
| 51 |
+
`endif
|
| 52 |
+
|
| 53 |
+
wire pll0_lock, pll1_lock, pll2_lock, pll_base, clk27;
|
| 54 |
+
|
| 55 |
+
assign pll_locked = pll0_lock & pll1_lock & pll2_lock;
|
| 56 |
+
|
| 57 |
+
`ifdef NEPTUNO
|
| 58 |
+
pll_neptuno u_pllneptuno(
|
| 59 |
+
.inclk0 ( clk_ext ),
|
| 60 |
+
.c0 ( clk27 ),
|
| 61 |
+
.locked ( pll0_lock )
|
| 62 |
+
);
|
| 63 |
+
`elsif POCKET
|
| 64 |
+
pll_pocket u_pllpocket( // converts 74.25 to 27MHz
|
| 65 |
+
.rst ( 1'b0 ),
|
| 66 |
+
.refclk ( clk_ext ),
|
| 67 |
+
.outclk_0( clk27 ),
|
| 68 |
+
.locked ( pll0_lock )
|
| 69 |
+
);
|
| 70 |
+
`else
|
| 71 |
+
assign clk27 = clk_ext;
|
| 72 |
+
assign pll0_lock = 1;
|
| 73 |
+
`endif
|
| 74 |
+
|
| 75 |
+
`JTFRAME_PLL u_basepll(
|
| 76 |
+
.inclk0 ( clk27 ),
|
| 77 |
+
.c0 ( pll_base ),
|
| 78 |
+
.locked ( pll2_lock )
|
| 79 |
+
);
|
| 80 |
+
|
| 81 |
+
// clk_rom is used for SDRAM access
|
| 82 |
+
// clk_sys is for video
|
| 83 |
+
// clk96, clk24 inputs to the core can be enabled via macros
|
| 84 |
+
`JTFRAME_GAMEPLL u_pll_game (
|
| 85 |
+
.inclk0 ( pll_base ),
|
| 86 |
+
.c0 ( SDRAM_CLK ), // 96 or 48 MHz (possibly phase shifted)
|
| 87 |
+
.c1 ( clk48 ), // 48 MHz
|
| 88 |
+
.c2 ( clk96 ),
|
| 89 |
+
.c3 ( clk24 ),
|
| 90 |
+
.c4 ( ),
|
| 91 |
+
.locked ( pll1_lock )
|
| 92 |
+
);
|
| 93 |
+
|
| 94 |
+
`ifdef JTFRAME_SDRAM96
|
| 95 |
+
assign clk_rom = clk96;
|
| 96 |
+
`else
|
| 97 |
+
assign clk_rom = clk48;
|
| 98 |
+
`endif
|
| 99 |
+
assign clk_sys = clk_rom;
|
| 100 |
+
|
| 101 |
+
jtframe_rst_sync u_reset96(
|
| 102 |
+
.rst ( game_rst ),
|
| 103 |
+
.clk ( clk96 ),
|
| 104 |
+
.rst_sync ( rst96 )
|
| 105 |
+
);
|
| 106 |
+
|
| 107 |
+
jtframe_rst_sync u_reset48(
|
| 108 |
+
.rst ( game_rst ),
|
| 109 |
+
.clk ( clk48 ),
|
| 110 |
+
.rst_sync ( rst48 )
|
| 111 |
+
);
|
| 112 |
+
|
| 113 |
+
jtframe_rst_sync u_reset24(
|
| 114 |
+
.rst ( game_rst ),
|
| 115 |
+
.clk ( clk24 ),
|
| 116 |
+
.rst_sync ( rst24 )
|
| 117 |
+
);
|
| 118 |
+
|
| 119 |
+
endmodule
|
snapshots/jotego_jtcores_pr1270/modules/jtframe/target/mist/hdl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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/* This file is part of JTFRAME.
|
| 2 |
+
JTFRAME program is free software: you can redistribute it and/or modify
|
| 3 |
+
it under the terms of the GNU General Public License as published by
|
| 4 |
+
the Free Software Foundation, either version 3 of the License, or
|
| 5 |
+
(at your option) any later version.
|
| 6 |
+
|
| 7 |
+
JTFRAME program is distributed in the hope that it will be useful,
|
| 8 |
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
| 9 |
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
| 10 |
+
GNU General Public License for more details.
|
| 11 |
+
|
| 12 |
+
You should have received a copy of the GNU General Public License
|
| 13 |
+
along with JTFRAME. If not, see <http://www.gnu.org/licenses/>.
|
| 14 |
+
|
| 15 |
+
Author: Jose Tejada Gomez. Twitter: @topapate
|
| 16 |
+
Version: 1.0
|
| 17 |
+
Date: 22-2-2019 */
|
| 18 |
+
|
| 19 |
+
// This is the MiST/SiDi128 top level
|
| 20 |
+
module mist_top #(parameter
|
| 21 |
+
VGA_DW = `ifdef MIST_VGA_8BIT 8 `else 6 `endif
|
| 22 |
+
)(
|
| 23 |
+
input [1:0] CLOCK_27,
|
| 24 |
+
|
| 25 |
+
output LED,
|
| 26 |
+
output [VGA_DW-1:0] VGA_R,
|
| 27 |
+
output [VGA_DW-1:0] VGA_G,
|
| 28 |
+
output [VGA_DW-1:0] VGA_B,
|
| 29 |
+
output VGA_HS,
|
| 30 |
+
output VGA_VS,
|
| 31 |
+
|
| 32 |
+
`ifdef MIST_USE_HDMI
|
| 33 |
+
output HDMI_RST,
|
| 34 |
+
output [7:0] HDMI_R,
|
| 35 |
+
output [7:0] HDMI_G,
|
| 36 |
+
output [7:0] HDMI_B,
|
| 37 |
+
output HDMI_HS,
|
| 38 |
+
output HDMI_VS,
|
| 39 |
+
output HDMI_PCLK,
|
| 40 |
+
output HDMI_DE,
|
| 41 |
+
inout HDMI_SDA,
|
| 42 |
+
inout HDMI_SCL,
|
| 43 |
+
input HDMI_INT,
|
| 44 |
+
`endif
|
| 45 |
+
|
| 46 |
+
input SPI_SCK,
|
| 47 |
+
inout SPI_DO,
|
| 48 |
+
input SPI_DI,
|
| 49 |
+
input SPI_SS2,
|
| 50 |
+
input SPI_SS3,
|
| 51 |
+
input CONF_DATA0,
|
| 52 |
+
|
| 53 |
+
`ifdef MIST_USE_QSPI
|
| 54 |
+
input QSCK,
|
| 55 |
+
input QCSn,
|
| 56 |
+
inout [3:0] QDAT,
|
| 57 |
+
`endif
|
| 58 |
+
`ifndef MIST_NO_DIRECT_UPLOAD
|
| 59 |
+
input SPI_SS4,
|
| 60 |
+
`endif
|
| 61 |
+
|
| 62 |
+
output [12:0] SDRAM_A,
|
| 63 |
+
inout [15:0] SDRAM_DQ,
|
| 64 |
+
output SDRAM_DQML,
|
| 65 |
+
output SDRAM_DQMH,
|
| 66 |
+
output SDRAM_nWE,
|
| 67 |
+
output SDRAM_nCAS,
|
| 68 |
+
output SDRAM_nRAS,
|
| 69 |
+
output SDRAM_nCS,
|
| 70 |
+
output [1:0] SDRAM_BA,
|
| 71 |
+
output SDRAM_CLK,
|
| 72 |
+
output SDRAM_CKE,
|
| 73 |
+
|
| 74 |
+
`ifdef MIST_DUAL_SDRAM
|
| 75 |
+
output [12:0] SDRAM2_A,
|
| 76 |
+
inout [15:0] SDRAM2_DQ,
|
| 77 |
+
output SDRAM2_DQML,
|
| 78 |
+
output SDRAM2_DQMH,
|
| 79 |
+
output SDRAM2_nWE,
|
| 80 |
+
output SDRAM2_nCAS,
|
| 81 |
+
output SDRAM2_nRAS,
|
| 82 |
+
output SDRAM2_nCS,
|
| 83 |
+
output [1:0] SDRAM2_BA,
|
| 84 |
+
output SDRAM2_CLK,
|
| 85 |
+
output SDRAM2_CKE,
|
| 86 |
+
`endif
|
| 87 |
+
|
| 88 |
+
output AUDIO_L,
|
| 89 |
+
output AUDIO_R,
|
| 90 |
+
`ifdef MIST_I2S_AUDIO
|
| 91 |
+
output I2S_BCK,
|
| 92 |
+
output I2S_LRCK,
|
| 93 |
+
output I2S_DATA,
|
| 94 |
+
`endif
|
| 95 |
+
`ifdef MIST_I2S_AUDIO_HDMI
|
| 96 |
+
output HDMI_MCLK,
|
| 97 |
+
output reg HDMI_BCK,
|
| 98 |
+
output reg HDMI_LRCK,
|
| 99 |
+
output reg HDMI_SDATA,
|
| 100 |
+
`endif
|
| 101 |
+
`ifdef MIST_SPDIF_AUDIO
|
| 102 |
+
output SPDIF,
|
| 103 |
+
`endif
|
| 104 |
+
|
| 105 |
+
input UART_RX,
|
| 106 |
+
output UART_TX
|
| 107 |
+
|
| 108 |
+
`ifdef SIMULATION
|
| 109 |
+
,output sim_pxl_cen,
|
| 110 |
+
output sim_pxl_clk,
|
| 111 |
+
output sim_vb,
|
| 112 |
+
output sim_hb,
|
| 113 |
+
output sim_dwnld_busy
|
| 114 |
+
`endif
|
| 115 |
+
|
| 116 |
+
);
|
| 117 |
+
|
| 118 |
+
`ifdef MIST_NO_DIRECT_UPLOAD
|
| 119 |
+
localparam bit DIRECT_UPLOAD = 0;
|
| 120 |
+
wire SPI_SS4 = 1;
|
| 121 |
+
`else
|
| 122 |
+
localparam bit DIRECT_UPLOAD = 1;
|
| 123 |
+
`endif
|
| 124 |
+
|
| 125 |
+
`ifdef MIST_USE_QSPI
|
| 126 |
+
localparam bit QSPI = 1;
|
| 127 |
+
assign QDAT = 4'hZ;
|
| 128 |
+
`else
|
| 129 |
+
localparam bit QSPI = 0;
|
| 130 |
+
`endif
|
| 131 |
+
|
| 132 |
+
`ifdef MIST_USE_HDMI
|
| 133 |
+
assign HDMI_RST = 1'b1;
|
| 134 |
+
localparam bit HDMI = 1;
|
| 135 |
+
`else
|
| 136 |
+
localparam bit HDMI = 0;
|
| 137 |
+
`endif
|
| 138 |
+
|
| 139 |
+
|
| 140 |
+
`ifdef MIST_DUAL_SDRAM
|
| 141 |
+
|
| 142 |
+
`ifdef JTFRAME_LF_SDRAM_BUFFER
|
| 143 |
+
`define MIST_USE_SDRAM2
|
| 144 |
+
`endif
|
| 145 |
+
`ifdef JTFRAME_VERTICAL
|
| 146 |
+
`ifdef JTFRAME_SDRAM_ROTATION
|
| 147 |
+
`define MIST_USE_SDRAM2
|
| 148 |
+
`define MIST_USE_SDRAM2_ROTATION
|
| 149 |
+
`endif
|
| 150 |
+
`endif
|
| 151 |
+
|
| 152 |
+
`ifndef MIST_USE_SDRAM2
|
| 153 |
+
assign SDRAM2_A = 13'hZZZZ;
|
| 154 |
+
assign SDRAM2_BA = 0;
|
| 155 |
+
assign SDRAM2_DQML = 1;
|
| 156 |
+
assign SDRAM2_DQMH = 1;
|
| 157 |
+
assign SDRAM2_CKE = 0;
|
| 158 |
+
assign SDRAM2_CLK = 0;
|
| 159 |
+
assign SDRAM2_nCS = 1;
|
| 160 |
+
assign SDRAM2_DQ = 16'hZZZZ;
|
| 161 |
+
assign SDRAM2_nCAS = 1;
|
| 162 |
+
assign SDRAM2_nRAS = 1;
|
| 163 |
+
assign SDRAM2_nWE = 1;
|
| 164 |
+
`endif
|
| 165 |
+
|
| 166 |
+
`endif // MIST_DUAL_SDRAM
|
| 167 |
+
|
| 168 |
+
`ifdef JTFRAME_SDRAM_LARGE
|
| 169 |
+
localparam SDRAMW=23; // 64 MB
|
| 170 |
+
`else
|
| 171 |
+
localparam SDRAMW=22; // 32 MB
|
| 172 |
+
`endif
|
| 173 |
+
|
| 174 |
+
wire rst, rst_n, clk_sys, clk_rom, clk24, clk48, clk96;
|
| 175 |
+
wire [63:0] status;
|
| 176 |
+
wire [31:0] joystick1, joystick2;
|
| 177 |
+
wire [25:0] ioctl_addr;
|
| 178 |
+
wire [ 7:0] ioctl_dout, ioctl_din;
|
| 179 |
+
wire ioctl_wr;
|
| 180 |
+
wire ioctl_ram;
|
| 181 |
+
wire [ 1:0] dial_x, dial_y;
|
| 182 |
+
|
| 183 |
+
wire [15:0] joyana_l1, joyana_l2, joyana_l3, joyana_l4,
|
| 184 |
+
joyana_r1, joyana_r2, joyana_r3, joyana_r4;
|
| 185 |
+
|
| 186 |
+
wire rst_req = status[0];
|
| 187 |
+
|
| 188 |
+
// ROM download
|
| 189 |
+
wire ioctl_rom, ioctl_cart, dwnld_busy;
|
| 190 |
+
|
| 191 |
+
wire [SDRAMW-1:0] prog_addr;
|
| 192 |
+
wire [15:0] prog_data;
|
| 193 |
+
wire [ 1:0] prog_mask, prog_ba;
|
| 194 |
+
wire prog_we, prog_rd, prog_rdy, prog_ack, prog_dst, prog_dok;
|
| 195 |
+
|
| 196 |
+
// ROM access from game
|
| 197 |
+
wire [SDRAMW-1:0] ba0_addr, ba1_addr, ba2_addr, ba3_addr;
|
| 198 |
+
wire [ 3:0] ba_rd, ba_rdy, ba_ack, ba_dst, ba_dok, ba_wr;
|
| 199 |
+
wire [15:0] ba0_din, ba1_din, ba2_din, ba3_din;
|
| 200 |
+
wire [ 1:0] ba0_dsn, ba1_dsn, ba2_dsn, ba3_dsn;
|
| 201 |
+
wire [15:0] sdram_dout;
|
| 202 |
+
|
| 203 |
+
localparam COLORW=`JTFRAME_COLORW;
|
| 204 |
+
|
| 205 |
+
wire [COLORW-1:0] red;
|
| 206 |
+
wire [COLORW-1:0] green;
|
| 207 |
+
wire [COLORW-1:0] blue;
|
| 208 |
+
|
| 209 |
+
wire LHBL, LVBL, hs, vs;
|
| 210 |
+
wire [15:0] snd_left, snd_right;
|
| 211 |
+
wire [ 5:0] snd_en, snd_vu;
|
| 212 |
+
wire [ 7:0] snd_vol;
|
| 213 |
+
wire snd_peak, sample;
|
| 214 |
+
|
| 215 |
+
wire [9:0] game_joy1, game_joy2, game_joy3, game_joy4;
|
| 216 |
+
wire [3:0] game_coin, game_start;
|
| 217 |
+
wire game_rst, game_service, game_tilt;
|
| 218 |
+
wire rst96, rst48, rst24;
|
| 219 |
+
wire [3:0] gfx_en;
|
| 220 |
+
// SDRAM
|
| 221 |
+
wire data_rdy, sdram_ack;
|
| 222 |
+
|
| 223 |
+
// PLL's
|
| 224 |
+
wire pll_locked, clk_pico;
|
| 225 |
+
|
| 226 |
+
|
| 227 |
+
`ifndef JTFRAME_STEREO
|
| 228 |
+
assign snd_right = snd_left;
|
| 229 |
+
`endif
|
| 230 |
+
|
| 231 |
+
jtframe_mist_clocks u_clocks(
|
| 232 |
+
.clk_ext ( CLOCK_27[0] ), // 27MHz for MiST, 50MHz for Neptuno
|
| 233 |
+
|
| 234 |
+
// PLL outputs
|
| 235 |
+
.clk96 ( clk96 ),
|
| 236 |
+
.clk48 ( clk48 ),
|
| 237 |
+
.clk24 ( clk24 ),
|
| 238 |
+
.pll_locked ( pll_locked ),
|
| 239 |
+
|
| 240 |
+
// System clocks
|
| 241 |
+
.clk_sys ( clk_sys ),
|
| 242 |
+
.clk_rom ( clk_rom ),
|
| 243 |
+
.SDRAM_CLK ( SDRAM_CLK ),
|
| 244 |
+
|
| 245 |
+
// reset signals
|
| 246 |
+
.game_rst ( game_rst ),
|
| 247 |
+
.rst96 ( rst96 ),
|
| 248 |
+
.rst48 ( rst48 ),
|
| 249 |
+
.rst24 ( rst24 )
|
| 250 |
+
);
|
| 251 |
+
|
| 252 |
+
assign clk_pico = clk48;
|
| 253 |
+
|
| 254 |
+
wire [ 7:0] debug_bus, debug_view;
|
| 255 |
+
wire [ 1:0] dip_fxlevel;
|
| 256 |
+
wire dip_pause, dip_flip, dip_test;
|
| 257 |
+
wire pxl_cen, pxl2_cen;
|
| 258 |
+
wire [ 7:0] st_addr, st_dout;
|
| 259 |
+
wire [ 7:0] paddle_1, paddle_2, paddle_3, paddle_4;
|
| 260 |
+
wire [15:0] mouse_1p, mouse_2p;
|
| 261 |
+
wire [ 1:0] mouse_strobe;
|
| 262 |
+
wire [ 8:0] gun_1p_x, gun_1p_y, gun_2p_x, gun_2p_y;
|
| 263 |
+
wire [31:0] dipsw;
|
| 264 |
+
|
| 265 |
+
`ifdef JTFRAME_DIPBASE
|
| 266 |
+
localparam DIPBASE=`JTFRAME_DIPBASE;
|
| 267 |
+
`else
|
| 268 |
+
localparam DIPBASE=16;
|
| 269 |
+
`endif
|
| 270 |
+
|
| 271 |
+
`ifdef MIST_I2S_AUDIO_HDMI
|
| 272 |
+
assign HDMI_MCLK = 0;
|
| 273 |
+
always @(posedge clk_sys) begin
|
| 274 |
+
HDMI_BCK <= I2S_BCK;
|
| 275 |
+
HDMI_LRCK <= I2S_LRCK;
|
| 276 |
+
HDMI_SDATA <= I2S_DATA;
|
| 277 |
+
end
|
| 278 |
+
`endif
|
| 279 |
+
|
| 280 |
+
jtframe_mist #(
|
| 281 |
+
.SDRAMW ( SDRAMW ),
|
| 282 |
+
.SIGNED_SND ( `JTFRAME_SIGNED_SND ),
|
| 283 |
+
// as MiST firmware can remap buttons, leaving it fixed here
|
| 284 |
+
// means the same game pad mapping will work for all games the same
|
| 285 |
+
.BUTTONS ( 6 ),
|
| 286 |
+
.DIPBASE ( DIPBASE ),
|
| 287 |
+
.COLORW ( COLORW ),
|
| 288 |
+
.VIDEO_WIDTH ( `JTFRAME_WIDTH ),
|
| 289 |
+
.VIDEO_HEIGHT ( `JTFRAME_HEIGHT),
|
| 290 |
+
.VGA_DW ( VGA_DW ),
|
| 291 |
+
.QSPI ( QSPI ),
|
| 292 |
+
.HDMI ( HDMI ),
|
| 293 |
+
.XOR_ROT ( 1'b1 ) // control rotation is on by default for MiST platforms as there is no hardware rotation
|
| 294 |
+
)
|
| 295 |
+
u_frame(
|
| 296 |
+
.clk_sys ( clk_sys ),
|
| 297 |
+
.clk_rom ( clk_rom ),
|
| 298 |
+
.clk_pico ( clk_pico ),
|
| 299 |
+
.pll_locked ( pll_locked ),
|
| 300 |
+
.status ( status ),
|
| 301 |
+
.dipsw ( dipsw ),
|
| 302 |
+
// Base video
|
| 303 |
+
.game_r ( red ),
|
| 304 |
+
.game_g ( green ),
|
| 305 |
+
.game_b ( blue ),
|
| 306 |
+
.LHBL ( LHBL ),
|
| 307 |
+
.LVBL ( LVBL ),
|
| 308 |
+
.hs ( hs ),
|
| 309 |
+
.vs ( vs ),
|
| 310 |
+
.pxl_cen ( pxl_cen ),
|
| 311 |
+
.pxl2_cen ( pxl2_cen ),
|
| 312 |
+
// MiST VGA pins
|
| 313 |
+
.VGA_R ( VGA_R ),
|
| 314 |
+
.VGA_G ( VGA_G ),
|
| 315 |
+
.VGA_B ( VGA_B ),
|
| 316 |
+
.VGA_HS ( VGA_HS ),
|
| 317 |
+
.VGA_VS ( VGA_VS ),
|
| 318 |
+
// HDMI pins
|
| 319 |
+
`ifdef MIST_USE_HDMI
|
| 320 |
+
.HDMI_R ( HDMI_R ),
|
| 321 |
+
.HDMI_G ( HDMI_G ),
|
| 322 |
+
.HDMI_B ( HDMI_B ),
|
| 323 |
+
.HDMI_HS ( HDMI_HS ),
|
| 324 |
+
.HDMI_VS ( HDMI_VS ),
|
| 325 |
+
.HDMI_PCLK ( HDMI_PCLK ),
|
| 326 |
+
.HDMI_DE ( HDMI_DE ),
|
| 327 |
+
.HDMI_SDA ( HDMI_SDA ),
|
| 328 |
+
.HDMI_SCL ( HDMI_SCL ),
|
| 329 |
+
`else
|
| 330 |
+
.HDMI_R ( ),
|
| 331 |
+
.HDMI_G ( ),
|
| 332 |
+
.HDMI_B ( ),
|
| 333 |
+
.HDMI_HS ( ),
|
| 334 |
+
.HDMI_VS ( ),
|
| 335 |
+
.HDMI_PCLK ( ),
|
| 336 |
+
.HDMI_DE ( ),
|
| 337 |
+
.HDMI_SDA ( ),
|
| 338 |
+
.HDMI_SCL ( ),
|
| 339 |
+
`endif
|
| 340 |
+
// UART
|
| 341 |
+
`ifndef JTFRAME_UART
|
| 342 |
+
.uart_rx ( UART_RX ),
|
| 343 |
+
.uart_tx ( UART_TX ),
|
| 344 |
+
`else
|
| 345 |
+
.uart_rx ( 1'b1 ),
|
| 346 |
+
.uart_tx ( ),
|
| 347 |
+
`endif
|
| 348 |
+
// SDRAM interface
|
| 349 |
+
.SDRAM_DQ ( SDRAM_DQ ),
|
| 350 |
+
.SDRAM_A ( SDRAM_A ),
|
| 351 |
+
.SDRAM_DQML ( SDRAM_DQML ),
|
| 352 |
+
.SDRAM_DQMH ( SDRAM_DQMH ),
|
| 353 |
+
.SDRAM_nWE ( SDRAM_nWE ),
|
| 354 |
+
.SDRAM_nCAS ( SDRAM_nCAS ),
|
| 355 |
+
.SDRAM_nRAS ( SDRAM_nRAS ),
|
| 356 |
+
.SDRAM_nCS ( SDRAM_nCS ),
|
| 357 |
+
.SDRAM_BA ( SDRAM_BA ),
|
| 358 |
+
.SDRAM_CKE ( SDRAM_CKE ),
|
| 359 |
+
`ifdef MIST_USE_SDRAM2_ROTATION
|
| 360 |
+
.sd_data ( SDRAM2_DQ ),
|
| 361 |
+
.sd_addr ( SDRAM2_A ),
|
| 362 |
+
.sd_dqm ( {SDRAM2_DQMH, SDRAM2_DQML} ),
|
| 363 |
+
.sd_ba ( SDRAM2_BA ),
|
| 364 |
+
.sd_cs ( SDRAM2_nCS ),
|
| 365 |
+
.sd_we ( SDRAM2_nWE ),
|
| 366 |
+
.sd_ras ( SDRAM2_nRAS ),
|
| 367 |
+
.sd_cas ( SDRAM2_nCAS ),
|
| 368 |
+
.sd_cke ( SDRAM2_CKE ),
|
| 369 |
+
`else
|
| 370 |
+
.sd_data ( ),
|
| 371 |
+
.sd_addr ( ),
|
| 372 |
+
.sd_dqm ( ),
|
| 373 |
+
.sd_ba ( ),
|
| 374 |
+
.sd_cs ( ),
|
| 375 |
+
.sd_we ( ),
|
| 376 |
+
.sd_ras ( ),
|
| 377 |
+
.sd_cas ( ),
|
| 378 |
+
.sd_cke ( ),
|
| 379 |
+
`endif
|
| 380 |
+
// SPI interface to arm io controller
|
| 381 |
+
.SPI_DO ( SPI_DO ),
|
| 382 |
+
.SPI_DI ( SPI_DI ),
|
| 383 |
+
.SPI_SCK ( SPI_SCK ),
|
| 384 |
+
.SPI_SS2 ( SPI_SS2 ),
|
| 385 |
+
.SPI_SS3 ( SPI_SS3 ),
|
| 386 |
+
.SPI_SS4 ( SPI_SS4 ),
|
| 387 |
+
.CONF_DATA0 ( CONF_DATA0 ),
|
| 388 |
+
`ifdef MIST_USE_QSPI
|
| 389 |
+
.QSCK ( QSCK ),
|
| 390 |
+
.QCSn ( QCSn ),
|
| 391 |
+
.QDAT ( QDAT ),
|
| 392 |
+
`else
|
| 393 |
+
.QSCK ( 1'b0 ),
|
| 394 |
+
.QCSn ( 1'b1 ),
|
| 395 |
+
.QDAT ( 4'h0 ),
|
| 396 |
+
`endif
|
| 397 |
+
// ROM access from game
|
| 398 |
+
.ba0_addr ( ba0_addr ), .ba1_addr ( ba1_addr ),
|
| 399 |
+
.ba2_addr ( ba2_addr ), .ba3_addr ( ba3_addr ),
|
| 400 |
+
.ba_rd ( ba_rd ), .ba_wr ( ba_wr ),
|
| 401 |
+
.ba_dst ( ba_dst ), .ba_dok ( ba_dok ),
|
| 402 |
+
.ba_rdy ( ba_rdy ), .ba_ack ( ba_ack ),
|
| 403 |
+
.ba0_din ( ba0_din ), .ba0_dsn ( ba0_dsn ),
|
| 404 |
+
.ba1_din ( ba1_din ), .ba1_dsn ( ba1_dsn ),
|
| 405 |
+
.ba2_din ( ba2_din ), .ba2_dsn ( ba2_dsn ),
|
| 406 |
+
.ba3_din ( ba3_din ), .ba3_dsn ( ba3_dsn ),
|
| 407 |
+
|
| 408 |
+
// ROM-load interface
|
| 409 |
+
.prog_addr ( prog_addr ),
|
| 410 |
+
.prog_ba ( prog_ba ),
|
| 411 |
+
.prog_rd ( prog_rd ),
|
| 412 |
+
.prog_we ( prog_we ),
|
| 413 |
+
.prog_data ( prog_data ),
|
| 414 |
+
.prog_mask ( prog_mask ),
|
| 415 |
+
.prog_ack ( prog_ack ),
|
| 416 |
+
.prog_dst ( prog_dst ),
|
| 417 |
+
.prog_dok ( prog_dok ),
|
| 418 |
+
.prog_rdy ( prog_rdy ),
|
| 419 |
+
|
| 420 |
+
// ROM load
|
| 421 |
+
.ioctl_addr ( ioctl_addr ),
|
| 422 |
+
.ioctl_dout ( ioctl_dout ),
|
| 423 |
+
.ioctl_din ( ioctl_din ),
|
| 424 |
+
.ioctl_wr ( ioctl_wr ),
|
| 425 |
+
.ioctl_ram ( ioctl_ram ),
|
| 426 |
+
|
| 427 |
+
.ioctl_rom ( ioctl_rom ),
|
| 428 |
+
.ioctl_cart ( ioctl_cart ),
|
| 429 |
+
.dwnld_busy ( dwnld_busy ),
|
| 430 |
+
|
| 431 |
+
.sdram_dout ( sdram_dout ),
|
| 432 |
+
//////////// board
|
| 433 |
+
.rst ( rst ),
|
| 434 |
+
.rst_n ( rst_n ), // unused
|
| 435 |
+
.game_rst ( game_rst ),
|
| 436 |
+
.game_rst_n ( ),
|
| 437 |
+
// reset forcing signals:
|
| 438 |
+
.rst_req ( rst_req ),
|
| 439 |
+
// Sound
|
| 440 |
+
.snd_left ( snd_left ),
|
| 441 |
+
.snd_right ( snd_right ),
|
| 442 |
+
.snd_sample ( sample ),
|
| 443 |
+
.snd_en ( snd_en ),
|
| 444 |
+
.snd_vu ( snd_vu ),
|
| 445 |
+
.snd_vol ( snd_vol ),
|
| 446 |
+
.snd_peak ( snd_peak ),
|
| 447 |
+
.AUDIO_L ( AUDIO_L ),
|
| 448 |
+
.AUDIO_R ( AUDIO_R ),
|
| 449 |
+
`ifdef MIST_I2S_AUDIO
|
| 450 |
+
.I2S_BCK ( I2S_BCK ),
|
| 451 |
+
.I2S_LRCK ( I2S_LRCK ),
|
| 452 |
+
.I2S_DATA ( I2S_DATA ),
|
| 453 |
+
`else
|
| 454 |
+
.I2S_BCK ( ),
|
| 455 |
+
.I2S_LRCK ( ),
|
| 456 |
+
.I2S_DATA ( ),
|
| 457 |
+
`endif
|
| 458 |
+
`ifdef MIST_SPDIF_AUDIO
|
| 459 |
+
.SPDIF ( SPDIF ),
|
| 460 |
+
`else
|
| 461 |
+
.SPDIF ( ),
|
| 462 |
+
`endif
|
| 463 |
+
// joystick
|
| 464 |
+
.game_joystick1 ( game_joy1 ),
|
| 465 |
+
.game_joystick2 ( game_joy2 ),
|
| 466 |
+
.game_joystick3 ( game_joy3 ),
|
| 467 |
+
.game_joystick4 ( game_joy4 ),
|
| 468 |
+
.game_coin ( game_coin ),
|
| 469 |
+
.game_start ( game_start ),
|
| 470 |
+
.game_service ( game_service ),
|
| 471 |
+
.game_tilt ( game_tilt ),
|
| 472 |
+
.joyana_l1 ( joyana_l1 ),
|
| 473 |
+
.joyana_l2 ( joyana_l2 ),
|
| 474 |
+
.joyana_l3 ( joyana_l3 ),
|
| 475 |
+
.joyana_l4 ( joyana_l4 ),
|
| 476 |
+
.joyana_r1 ( joyana_r1 ),
|
| 477 |
+
.joyana_r2 ( joyana_r2 ),
|
| 478 |
+
.joyana_r3 ( joyana_r3 ),
|
| 479 |
+
.joyana_r4 ( joyana_r4 ),
|
| 480 |
+
// Paddle inputs
|
| 481 |
+
.paddle_1 ( paddle_1 ),
|
| 482 |
+
.paddle_2 ( paddle_2 ),
|
| 483 |
+
.paddle_3 ( paddle_3 ),
|
| 484 |
+
.paddle_4 ( paddle_4 ),
|
| 485 |
+
// Mouse inputs
|
| 486 |
+
.mouse_1p ( mouse_1p ),
|
| 487 |
+
.mouse_2p ( mouse_2p ),
|
| 488 |
+
.mouse_strobe ( mouse_strobe ),
|
| 489 |
+
.LED ( LED ),
|
| 490 |
+
// Lightguns position
|
| 491 |
+
.gun_1p_x ( gun_1p_x ),
|
| 492 |
+
.gun_1p_y ( gun_1p_y ),
|
| 493 |
+
.gun_2p_x ( gun_2p_x ),
|
| 494 |
+
.gun_2p_y ( gun_2p_y ),
|
| 495 |
+
// Dial emulation
|
| 496 |
+
.dial_x ( dial_x ),
|
| 497 |
+
.dial_y ( dial_y ),
|
| 498 |
+
// Unused in MiST
|
| 499 |
+
.BUTTON_n ( 4'hf ),
|
| 500 |
+
.ps2_clk ( ),
|
| 501 |
+
.ps2_dout ( ),
|
| 502 |
+
.joy1_bus ( ),
|
| 503 |
+
.joy2_bus ( ),
|
| 504 |
+
.JOY_SELECT ( ),
|
| 505 |
+
// DIP and OSD settings
|
| 506 |
+
.dip_test ( dip_test ),
|
| 507 |
+
.dip_pause ( dip_pause ),
|
| 508 |
+
.dip_flip ( dip_flip ),
|
| 509 |
+
.dip_fxlevel ( dip_fxlevel ),
|
| 510 |
+
// status
|
| 511 |
+
.st_addr ( st_addr ),
|
| 512 |
+
.st_dout ( st_dout ),
|
| 513 |
+
// Debug
|
| 514 |
+
.gfx_en ( gfx_en ),
|
| 515 |
+
.debug_bus ( debug_bus ),
|
| 516 |
+
.debug_view ( debug_view )
|
| 517 |
+
);
|
| 518 |
+
|
| 519 |
+
wire game_tx, game_rx;
|
| 520 |
+
|
| 521 |
+
`ifdef JTFRAME_UART
|
| 522 |
+
assign UART_TX = game_tx,
|
| 523 |
+
game_rx = UART_RX;
|
| 524 |
+
`endif
|
| 525 |
+
|
| 526 |
+
`ifdef MIST_USE_SDRAM2
|
| 527 |
+
// implement video buffer in the second SDRAM chip (sidi128)
|
| 528 |
+
wire pll_locked2, clk_rom2;
|
| 529 |
+
|
| 530 |
+
jtframe_mist_clocks u_clocks2(
|
| 531 |
+
.clk_ext ( CLOCK_27[0] ), // 27MHz for MiST, 50MHz for Neptuno
|
| 532 |
+
|
| 533 |
+
// PLL outputs
|
| 534 |
+
.clk96 ( ),
|
| 535 |
+
.clk48 ( ),
|
| 536 |
+
.clk24 ( ),
|
| 537 |
+
.pll_locked ( pll_locked2 ),
|
| 538 |
+
|
| 539 |
+
// System clocks
|
| 540 |
+
.clk_sys ( ),
|
| 541 |
+
.clk_rom ( clk_rom2 ),
|
| 542 |
+
.SDRAM_CLK ( SDRAM2_CLK ),
|
| 543 |
+
|
| 544 |
+
// reset signals
|
| 545 |
+
.game_rst ( ),
|
| 546 |
+
.rst96 ( ),
|
| 547 |
+
.rst48 ( ),
|
| 548 |
+
.rst24 ( )
|
| 549 |
+
);
|
| 550 |
+
`endif
|
| 551 |
+
|
| 552 |
+
`ifdef JTFRAME_LF_BUFFER
|
| 553 |
+
// line-frame buffer
|
| 554 |
+
wire [ 7:0] game_vrender;
|
| 555 |
+
wire [ 8:0] game_hdump;
|
| 556 |
+
wire [ 8:0] ln_addr;
|
| 557 |
+
wire [15:0] ln_data;
|
| 558 |
+
wire ln_done;
|
| 559 |
+
wire ln_we;
|
| 560 |
+
wire ln_hs, ln_vs, ln_lvbl;
|
| 561 |
+
wire [15:0] ln_pxl;
|
| 562 |
+
wire [ 7:0] ln_v;
|
| 563 |
+
|
| 564 |
+
wire [ 7:0] st_lpbuf;
|
| 565 |
+
|
| 566 |
+
// this places the pxl1_cen in the pixel centre
|
| 567 |
+
reg pxl1_cen;
|
| 568 |
+
always @(posedge clk_sys) pxl1_cen <= pxl2_cen & ~pxl_cen;
|
| 569 |
+
|
| 570 |
+
`ifdef JTFRAME_LF_SDRAM_BUFFER
|
| 571 |
+
jtframe_lfbuf_sdr u_lf_buf(
|
| 572 |
+
.rst ( rst ),
|
| 573 |
+
.clk ( clk_rom2 ),
|
| 574 |
+
.pxl_cen ( pxl1_cen ),
|
| 575 |
+
|
| 576 |
+
.hs ( hs ),
|
| 577 |
+
.vs ( vs ),
|
| 578 |
+
.lvbl ( LVBL ),
|
| 579 |
+
.lhbl ( LHBL ),
|
| 580 |
+
.vrender ( game_vrender ),
|
| 581 |
+
.hdump ( game_hdump ),
|
| 582 |
+
|
| 583 |
+
// interface with the game core
|
| 584 |
+
.ln_addr ( ln_addr ),
|
| 585 |
+
.ln_data ( ln_data ),
|
| 586 |
+
.ln_done ( ln_done ),
|
| 587 |
+
.ln_hs ( ln_hs ),
|
| 588 |
+
.ln_pxl ( ln_pxl ),
|
| 589 |
+
.ln_v ( ln_v ),
|
| 590 |
+
.ln_vs ( ln_vs ),
|
| 591 |
+
.ln_lvbl ( ln_lvbl ),
|
| 592 |
+
.ln_we ( ln_we ),
|
| 593 |
+
|
| 594 |
+
.init_n ( pll_locked2 ),
|
| 595 |
+
.SDRAM_A ( SDRAM2_A ),
|
| 596 |
+
.SDRAM_DQ ( SDRAM2_DQ ),
|
| 597 |
+
.SDRAM_DQML ( SDRAM2_DQML ),
|
| 598 |
+
.SDRAM_DQMH ( SDRAM2_DQMH ),
|
| 599 |
+
.SDRAM_nWE ( SDRAM2_nWE ),
|
| 600 |
+
.SDRAM_nCAS ( SDRAM2_nCAS ),
|
| 601 |
+
.SDRAM_nRAS ( SDRAM2_nRAS ),
|
| 602 |
+
.SDRAM_nCS ( SDRAM2_nCS ),
|
| 603 |
+
.SDRAM_BA ( SDRAM2_BA ),
|
| 604 |
+
.SDRAM_CKE ( SDRAM2_CKE ),
|
| 605 |
+
|
| 606 |
+
.st_addr ( st_addr ),
|
| 607 |
+
.st_dout ( st_lpbuf )
|
| 608 |
+
);
|
| 609 |
+
`else
|
| 610 |
+
// line-frame buffer
|
| 611 |
+
jtframe_lfbuf_bram u_lf_buf(
|
| 612 |
+
.rst ( rst ),
|
| 613 |
+
.clk ( clk_rom ),
|
| 614 |
+
.pxl_cen ( pxl1_cen ),
|
| 615 |
+
|
| 616 |
+
.hs ( hs ),
|
| 617 |
+
.vs ( vs ),
|
| 618 |
+
.lvbl ( LVBL ),
|
| 619 |
+
.lhbl ( LHBL ),
|
| 620 |
+
.vrender ( game_vrender ),
|
| 621 |
+
.hdump ( game_hdump ),
|
| 622 |
+
|
| 623 |
+
// interface with the game core
|
| 624 |
+
.ln_addr ( ln_addr ),
|
| 625 |
+
.ln_data ( ln_data ),
|
| 626 |
+
.ln_done ( ln_done ),
|
| 627 |
+
.ln_hs ( ln_hs ),
|
| 628 |
+
.ln_pxl ( ln_pxl ),
|
| 629 |
+
.ln_v ( ln_v ),
|
| 630 |
+
.ln_vs ( ln_vs ),
|
| 631 |
+
.ln_lvbl ( ln_lvbl ),
|
| 632 |
+
.ln_we ( ln_we ),
|
| 633 |
+
|
| 634 |
+
.st_addr ( st_addr ),
|
| 635 |
+
.st_dout ( st_lpbuf )
|
| 636 |
+
);
|
| 637 |
+
`endif
|
| 638 |
+
`endif
|
| 639 |
+
|
| 640 |
+
`include "jtframe_game_instance.v"
|
| 641 |
+
|
| 642 |
+
endmodule
|
snapshots/jotego_jtcores_pr1270/modules/jtframe/target/mist/hdl/jtframe_mist_video.v
ADDED
|
@@ -0,0 +1,324 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/* This file is part of JTFRAME.
|
| 2 |
+
JTFRAME program is free software: you can redistribute it and/or modify
|
| 3 |
+
it under the terms of the GNU General Public License as published by
|
| 4 |
+
the Free Software Foundation, either version 3 of the License, or
|
| 5 |
+
(at your option) any later version.
|
| 6 |
+
|
| 7 |
+
JTFRAME program is distributed in the hope that it will be useful,
|
| 8 |
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
| 9 |
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
| 10 |
+
GNU General Public License for more details.
|
| 11 |
+
|
| 12 |
+
You should have received a copy of the GNU General Public License
|
| 13 |
+
along with JTFRAME. If not, see <http://www.gnu.org/licenses/>.
|
| 14 |
+
|
| 15 |
+
Author: Jose Tejada Gomez. Twitter: @topapate
|
| 16 |
+
Version: 1.0
|
| 17 |
+
Date: 27-10-2017 */
|
| 18 |
+
|
| 19 |
+
module jtframe_mist_video #(parameter
|
| 20 |
+
COLORW=4,
|
| 21 |
+
VGA_DW=6,
|
| 22 |
+
VIDEO_WIDTH=256,
|
| 23 |
+
OSD=1
|
| 24 |
+
)(
|
| 25 |
+
input rst,
|
| 26 |
+
input clk,
|
| 27 |
+
// base video
|
| 28 |
+
input pxl_cen,
|
| 29 |
+
input pxl2_cen,
|
| 30 |
+
input game_hs,
|
| 31 |
+
input game_vs,
|
| 32 |
+
input game_lvbl,
|
| 33 |
+
input game_lhbl,
|
| 34 |
+
input [3*COLORW-1:0] game_rgb,
|
| 35 |
+
// SPI for OSD contents
|
| 36 |
+
input osd_di, osd_sck, osd_ss3,
|
| 37 |
+
input [1:0] osd_rotate,
|
| 38 |
+
output osd_shown,
|
| 39 |
+
// low pass filter for video
|
| 40 |
+
input bw_en,
|
| 41 |
+
input blend_en,
|
| 42 |
+
input [1:0] scanlines,
|
| 43 |
+
input [1:0] rotation, // 0 - no rotation, 1 - clockwise, 2 - anticlockwise
|
| 44 |
+
// video signal type
|
| 45 |
+
input ypbpr,
|
| 46 |
+
input no_csync,
|
| 47 |
+
input scan2x_en, // scan doubler enable
|
| 48 |
+
input sog, //Sync-On-Green
|
| 49 |
+
input cvideo_en,
|
| 50 |
+
input pal_en,
|
| 51 |
+
// Scan-doubler video
|
| 52 |
+
output reg [7:0] scan2x_r,
|
| 53 |
+
output reg [7:0] scan2x_g,
|
| 54 |
+
output reg [7:0] scan2x_b,
|
| 55 |
+
output scan2x_hs,
|
| 56 |
+
output scan2x_vs,
|
| 57 |
+
output scan2x_de,
|
| 58 |
+
output scan2x_HB,
|
| 59 |
+
output scan2x_VB,
|
| 60 |
+
// crt video
|
| 61 |
+
output reg video_hs,
|
| 62 |
+
output reg video_vs,
|
| 63 |
+
output video_de,
|
| 64 |
+
output [VGA_DW-1:0] video_r,
|
| 65 |
+
output [VGA_DW-1:0] video_g,
|
| 66 |
+
output [VGA_DW-1:0] video_b,
|
| 67 |
+
// Composite video
|
| 68 |
+
output [23:0] yc_vid,
|
| 69 |
+
// SDRAM interface for rotation
|
| 70 |
+
input init,
|
| 71 |
+
inout [15:0] sd_data,
|
| 72 |
+
output [12:0] sd_addr,
|
| 73 |
+
output [1:0] sd_dqm,
|
| 74 |
+
output [1:0] sd_ba,
|
| 75 |
+
output sd_cs,
|
| 76 |
+
output sd_we,
|
| 77 |
+
output sd_ras,
|
| 78 |
+
output sd_cas,
|
| 79 |
+
output sd_cke
|
| 80 |
+
);
|
| 81 |
+
`ifdef SIMULATION
|
| 82 |
+
always @* begin
|
| 83 |
+
video_hs = game_hs;
|
| 84 |
+
video_vs = game_vs;
|
| 85 |
+
end
|
| 86 |
+
|
| 87 |
+
assign video_r = game_rgb[3*VGA_DW-1-:COLORW];
|
| 88 |
+
assign video_g = game_rgb[2*VGA_DW-1-:COLORW];
|
| 89 |
+
assign video_b = game_rgb[ VGA_DW-1-:COLORW];
|
| 90 |
+
`else
|
| 91 |
+
// Limited bandwidth for video signal
|
| 92 |
+
localparam CLROUTW = COLORW < 5 ? COLORW+1 : COLORW;
|
| 93 |
+
|
| 94 |
+
wire [CLROUTW-1:0] r_ana, g_ana, b_ana;
|
| 95 |
+
wire hs_ana, vs_ana, lhbl_ana, lvbl_ana;
|
| 96 |
+
wire pxl_ana;
|
| 97 |
+
|
| 98 |
+
jtframe_wirebw #(.WIN(COLORW), .WOUT(CLROUTW)) u_wirebw(
|
| 99 |
+
.clk ( clk ),
|
| 100 |
+
.spl_in ( pxl_cen ),
|
| 101 |
+
.r_in ( game_rgb[COLORW*2+:COLORW] ),
|
| 102 |
+
.g_in ( game_rgb[COLORW*1+:COLORW] ),
|
| 103 |
+
.b_in ( game_rgb[COLORW*0+:COLORW] ),
|
| 104 |
+
.HS_in ( game_hs ),
|
| 105 |
+
.VS_in ( game_vs ),
|
| 106 |
+
.LHB_in ( game_lhbl ),
|
| 107 |
+
.LVB_in ( game_lvbl ),
|
| 108 |
+
.enable ( bw_en ),
|
| 109 |
+
// filtered video
|
| 110 |
+
.HS_out ( hs_ana ),
|
| 111 |
+
.VS_out ( vs_ana ),
|
| 112 |
+
.LHB_out ( lhbl_ana ),
|
| 113 |
+
.LVB_out ( lvbl_ana ),
|
| 114 |
+
.r_out ( r_ana ),
|
| 115 |
+
.g_out ( g_ana ),
|
| 116 |
+
.b_out ( b_ana )
|
| 117 |
+
);
|
| 118 |
+
/* verilator lint_off WIDTHTRUNC */
|
| 119 |
+
/* verilator lint_off WIDTHEXPAND */
|
| 120 |
+
/* verilator lint_off SELRANGE */
|
| 121 |
+
function [7:0] extend8(input [CLROUTW-1:0] a); begin
|
| 122 |
+
extend8[7-:CLROUTW] = a;
|
| 123 |
+
if( CLROUTW >= 8) extend8 = a[CLROUTW-1-: 8];
|
| 124 |
+
case( CLROUTW )
|
| 125 |
+
3: extend8[4:0] = { a[CLROUTW-1-:3], a[CLROUTW-1-:2]};
|
| 126 |
+
4: extend8[3:0] = { a[CLROUTW-1-:3], a[0]};
|
| 127 |
+
5: extend8[2:0] = a[CLROUTW-1-:3];
|
| 128 |
+
6: extend8[1:0] = a[CLROUTW-1-:2];
|
| 129 |
+
7: extend8[0] = a[CLROUTW-1];
|
| 130 |
+
default: ;
|
| 131 |
+
endcase
|
| 132 |
+
end endfunction
|
| 133 |
+
/* verilator lint_on WIDTHTRUNC */
|
| 134 |
+
/* verilator lint_on WIDTHEXPAND */
|
| 135 |
+
/* verilator lint_on SELRANGE */
|
| 136 |
+
|
| 137 |
+
// This scan doubler takes very little memory. Some games in MiST
|
| 138 |
+
// can only use this
|
| 139 |
+
wire [CLROUTW*3-1:0] rgbx2;
|
| 140 |
+
wire [CLROUTW*3-1:0] ana_rgb = { r_ana, g_ana, b_ana };
|
| 141 |
+
wire scan2x_enb = cvideo_en ? 1'b1 : ~scan2x_en;
|
| 142 |
+
wire scan2x_vsin = bw_en ? vs_ana : game_vs;
|
| 143 |
+
wire scan2x_hsin = bw_en ? hs_ana : game_hs;
|
| 144 |
+
wire scan2x_hbin = bw_en ? ~lhbl_ana : ~game_lhbl;
|
| 145 |
+
wire scan2x_vbin = bw_en ? ~lvbl_ana : ~game_lvbl;
|
| 146 |
+
|
| 147 |
+
// Note that VIDEO_WIDTH must include blanking for jtframe_scan2x
|
| 148 |
+
jtframe_scan2x #(.COLORW(CLROUTW), .HLEN(VIDEO_WIDTH)) u_scan2x(
|
| 149 |
+
.rst ( rst ),
|
| 150 |
+
.clk ( clk ),
|
| 151 |
+
.pxl_cen ( pxl_cen ),
|
| 152 |
+
// settings
|
| 153 |
+
.sl_mode ( scanlines[1:0] ),
|
| 154 |
+
.blend_en ( ~|rotation & blend_en ),
|
| 155 |
+
.enb ( scan2x_enb ),
|
| 156 |
+
.rotation ( rotation ),
|
| 157 |
+
.hfilter ( blend_en ),
|
| 158 |
+
.vfilter ( blend_en ),
|
| 159 |
+
// video inputs
|
| 160 |
+
.pxl2_cen ( pxl2_cen ),
|
| 161 |
+
.x1_pxl ( ana_rgb ),
|
| 162 |
+
.x1_hs ( scan2x_hsin ),
|
| 163 |
+
.x1_vs ( scan2x_vsin ),
|
| 164 |
+
.x1_hb ( scan2x_hbin ),
|
| 165 |
+
.x1_vb ( scan2x_vbin ),
|
| 166 |
+
// outputs
|
| 167 |
+
.x2_pxl ( rgbx2 ),
|
| 168 |
+
.x2_hs ( scan2x_hs ),
|
| 169 |
+
.x2_vs ( scan2x_vs ),
|
| 170 |
+
.x2_de ( scan2x_de ),
|
| 171 |
+
.x2_HB ( scan2x_HB ),
|
| 172 |
+
.x2_VB ( scan2x_VB ),
|
| 173 |
+
// RAM interface for rotation
|
| 174 |
+
.init ( init ),
|
| 175 |
+
.sd_data ( sd_data ),
|
| 176 |
+
.sd_addr ( sd_addr ),
|
| 177 |
+
.sd_dqm ( sd_dqm ),
|
| 178 |
+
.sd_ba ( sd_ba ),
|
| 179 |
+
.sd_cs ( sd_cs ),
|
| 180 |
+
.sd_we ( sd_we ),
|
| 181 |
+
.sd_ras ( sd_ras ),
|
| 182 |
+
.sd_cas ( sd_cas ),
|
| 183 |
+
.sd_cke ( sd_cke )
|
| 184 |
+
);
|
| 185 |
+
|
| 186 |
+
always @* begin
|
| 187 |
+
scan2x_r <= extend8( rgbx2[CLROUTW*3-1:CLROUTW*2] );
|
| 188 |
+
scan2x_g <= extend8( rgbx2[CLROUTW*2-1:CLROUTW] );
|
| 189 |
+
scan2x_b <= extend8( rgbx2[CLROUTW-1:0] );
|
| 190 |
+
end
|
| 191 |
+
|
| 192 |
+
// on-screen display
|
| 193 |
+
localparam m = VGA_DW/COLORW;
|
| 194 |
+
localparam n = VGA_DW%COLORW;
|
| 195 |
+
|
| 196 |
+
wire [VGA_DW-1:0] osd_r_o;
|
| 197 |
+
wire [VGA_DW-1:0] osd_g_o;
|
| 198 |
+
wire [VGA_DW-1:0] osd_b_o;
|
| 199 |
+
wire VSync_osd, HSync_osd, CSync_osd, de_osd;
|
| 200 |
+
|
| 201 |
+
assign CSync_osd = ~(HSync_osd ^ VSync_osd);
|
| 202 |
+
|
| 203 |
+
generate
|
| 204 |
+
if(OSD==1) begin
|
| 205 |
+
osd #(0,0,6'b01_11_01,VGA_DW) osd (
|
| 206 |
+
.clk_sys ( clk ),
|
| 207 |
+
// spi for OSD
|
| 208 |
+
.SPI_DI ( osd_di ),
|
| 209 |
+
.SPI_SCK ( osd_sck ),
|
| 210 |
+
.SPI_SS3 ( osd_ss3 ),
|
| 211 |
+
|
| 212 |
+
.rotate ( osd_rotate ),
|
| 213 |
+
|
| 214 |
+
.R_in ( scan2x_r[7-:VGA_DW] ),
|
| 215 |
+
.G_in ( scan2x_g[7-:VGA_DW] ),
|
| 216 |
+
.B_in ( scan2x_b[7-:VGA_DW] ),
|
| 217 |
+
.HSync ( scan2x_hs ),
|
| 218 |
+
.VSync ( scan2x_vs ),
|
| 219 |
+
.DE ( scan2x_de ),
|
| 220 |
+
|
| 221 |
+
.R_out ( osd_r_o ),
|
| 222 |
+
.G_out ( osd_g_o ),
|
| 223 |
+
.B_out ( osd_b_o ),
|
| 224 |
+
.HSync_out ( HSync_osd ),
|
| 225 |
+
.VSync_out ( VSync_osd ),
|
| 226 |
+
.DE_out ( de_osd ),
|
| 227 |
+
|
| 228 |
+
.osd_shown ( osd_shown )
|
| 229 |
+
);
|
| 230 |
+
end else begin
|
| 231 |
+
assign {osd_r_o, osd_g_o, osd_b_o,HSync_osd,VSync_osd,de_osd} =
|
| 232 |
+
{ scan2x_r[7-:VGA_DW], scan2x_g[7-:VGA_DW], scan2x_b[7-:VGA_DW],
|
| 233 |
+
scan2x_hs,scan2x_vs,scan2x_de };
|
| 234 |
+
assign osd_shown = 0;
|
| 235 |
+
end
|
| 236 |
+
endgenerate
|
| 237 |
+
|
| 238 |
+
wire HSync_out, VSync_out, CSync_out;
|
| 239 |
+
|
| 240 |
+
RGBtoYPbPr #(VGA_DW) u_rgb2ypbpr(
|
| 241 |
+
.clk ( clk ),
|
| 242 |
+
.ena ( ypbpr ),
|
| 243 |
+
.red_in ( osd_r_o ),
|
| 244 |
+
.green_in ( osd_g_o ),
|
| 245 |
+
.blue_in ( osd_b_o ),
|
| 246 |
+
.hs_in ( HSync_osd ),
|
| 247 |
+
.vs_in ( VSync_osd ),
|
| 248 |
+
.cs_in ( CSync_osd ),
|
| 249 |
+
.de_in ( de_osd ),
|
| 250 |
+
.red_out ( video_r ),
|
| 251 |
+
.green_out ( video_g ),
|
| 252 |
+
.blue_out ( video_b ),
|
| 253 |
+
.hs_out ( HSync_out ),
|
| 254 |
+
.vs_out ( VSync_out ),
|
| 255 |
+
.cs_out ( CSync_out ),
|
| 256 |
+
.de_out ( video_de )
|
| 257 |
+
);
|
| 258 |
+
|
| 259 |
+
function [7:0] extend8v( input [VGA_DW-1:0] a); begin
|
| 260 |
+
extend8v[7-:VGA_DW] = a;
|
| 261 |
+
if( VGA_DW >= 8) extend8v = a[VGA_DW-1-: 8];
|
| 262 |
+
case( VGA_DW )
|
| 263 |
+
3: extend8v[4:0] = { a[VGA_DW-1-:3], a[VGA_DW-1-:2]};
|
| 264 |
+
4: extend8v[3:0] = { a[VGA_DW-1-:3], a[0]};
|
| 265 |
+
5: extend8v[2:0] = a[VGA_DW-1-:3];
|
| 266 |
+
6: extend8v[1:0] = a[VGA_DW-1-:2];
|
| 267 |
+
7: extend8v[0] = a[VGA_DW-1];
|
| 268 |
+
default: ;
|
| 269 |
+
endcase
|
| 270 |
+
end endfunction
|
| 271 |
+
|
| 272 |
+
wire hsync_c, vsync_c, csync_c;
|
| 273 |
+
wire [23:0] colours;
|
| 274 |
+
wire [26:0] colorburst;
|
| 275 |
+
wire [31:0] phase_inc;
|
| 276 |
+
reg [ 7:0] video_r8, video_g8, video_b8;
|
| 277 |
+
|
| 278 |
+
always @* begin
|
| 279 |
+
video_r8 = extend8v( video_r );
|
| 280 |
+
video_g8 = extend8v( video_g );
|
| 281 |
+
video_b8 = extend8v( video_b );
|
| 282 |
+
end
|
| 283 |
+
|
| 284 |
+
localparam [31:0] JTFRAME_PAL =`JTFRAME_PAL;
|
| 285 |
+
localparam [31:0] JTFRAME_NTSC =`JTFRAME_NTSC;
|
| 286 |
+
localparam [16:0] JTFRAME_PAL_LEN = `JTFRAME_PAL_LEN;
|
| 287 |
+
localparam [16:0] JTFRAME_NTSC_LEN = `JTFRAME_NTSC_LEN;
|
| 288 |
+
|
| 289 |
+
assign phase_inc = pal_en ? JTFRAME_PAL : JTFRAME_NTSC;
|
| 290 |
+
assign colorburst = {JTFRAME_NTSC_LEN, JTFRAME_PAL_LEN[9:0]}; // pal/ntsc selection for colorburst is donde in the module
|
| 291 |
+
assign colours = {video_r8, video_g8, video_b8};
|
| 292 |
+
|
| 293 |
+
yc_out u_yc(
|
| 294 |
+
.clk ( clk ),
|
| 295 |
+
.PHASE_INC ( {phase_inc,8'b0} ), /* 40'd80070078948>>1 */
|
| 296 |
+
.PAL_EN ( pal_en ),
|
| 297 |
+
.CVBS ( 1'b0 ),
|
| 298 |
+
.COLORBURST_RANGE ( colorburst ), /* 16'd42145 */
|
| 299 |
+
.hsync ( HSync_out ),
|
| 300 |
+
.vsync ( VSync_out ),
|
| 301 |
+
.csync ( CSync_out ),
|
| 302 |
+
.din ( colours & {24{video_de}} ),
|
| 303 |
+
.dout ( yc_vid ),
|
| 304 |
+
.hsync_o ( hsync_c ),
|
| 305 |
+
.vsync_o ( vsync_c ),
|
| 306 |
+
.csync_o ( csync_c )
|
| 307 |
+
);
|
| 308 |
+
|
| 309 |
+
// a minimig vga->scart cable expects a composite sync signal on the VIDEO_HS output.
|
| 310 |
+
// and VCC on VIDEO_VS (to switch into rgb mode)
|
| 311 |
+
always @(posedge clk) begin
|
| 312 |
+
video_hs <= ( (~no_csync & scan2x_enb) | ypbpr) ? CSync_out : HSync_out;
|
| 313 |
+
video_vs <= ( (~no_csync & scan2x_enb) | ypbpr) ? 1'b1 : VSync_out;
|
| 314 |
+
if( sog ) begin
|
| 315 |
+
video_hs <= 1'b1;
|
| 316 |
+
video_vs <= CSync_out;
|
| 317 |
+
end
|
| 318 |
+
if( cvideo_en ) begin
|
| 319 |
+
video_hs <= csync_c;
|
| 320 |
+
video_vs <= 1'b1;
|
| 321 |
+
end
|
| 322 |
+
end
|
| 323 |
+
`endif
|
| 324 |
+
endmodule
|
snapshots/jotego_jtcores_pr1270/modules/jtframe/target/mist/hdl/osd.sv
ADDED
|
@@ -0,0 +1,411 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// A simple OSD implementation. Can be hooked up between a cores
|
| 2 |
+
// VGA output and the physical VGA pins
|
| 3 |
+
|
| 4 |
+
module osd #(
|
| 5 |
+
parameter [9:0] OSD_X_OFFSET = 10'd0,
|
| 6 |
+
parameter [9:0] OSD_Y_OFFSET = 10'd0,
|
| 7 |
+
parameter [5:0] OSD_COLOR = `ifdef JTFRAME_OSDCOLOR `JTFRAME_OSDCOLOR `else 6'b101010 `endif ,
|
| 8 |
+
parameter OSD_DW = 6
|
| 9 |
+
)(
|
| 10 |
+
// OSDs pixel clock, should be synchronous to cores pixel clock to
|
| 11 |
+
// avoid jitter.
|
| 12 |
+
input clk_sys,
|
| 13 |
+
|
| 14 |
+
// SPI interface
|
| 15 |
+
input SPI_SCK,
|
| 16 |
+
input SPI_SS3,
|
| 17 |
+
input SPI_DI,
|
| 18 |
+
|
| 19 |
+
input [1:0] rotate, //[0] - rotate [1] - left or right
|
| 20 |
+
|
| 21 |
+
// VGA signals coming from core
|
| 22 |
+
input [OSD_DW-1:0] R_in,
|
| 23 |
+
input [OSD_DW-1:0] G_in,
|
| 24 |
+
input [OSD_DW-1:0] B_in,
|
| 25 |
+
input HSync,
|
| 26 |
+
input VSync,
|
| 27 |
+
input DE,
|
| 28 |
+
|
| 29 |
+
// VGA signals going to video connector
|
| 30 |
+
output reg [OSD_DW-1:0] R_out,
|
| 31 |
+
output reg [OSD_DW-1:0] G_out,
|
| 32 |
+
output reg [OSD_DW-1:0] B_out,
|
| 33 |
+
|
| 34 |
+
output reg HSync_out,
|
| 35 |
+
output reg VSync_out,
|
| 36 |
+
output reg DE_out,
|
| 37 |
+
|
| 38 |
+
output reg osd_shown
|
| 39 |
+
);
|
| 40 |
+
|
| 41 |
+
`ifndef JTFRAME_OSDCOLOR
|
| 42 |
+
`ifdef JTFRAME_RELEASE
|
| 43 |
+
`define JTFRAME_OSDCOLOR (~6'b0)
|
| 44 |
+
`else
|
| 45 |
+
`define JTFRAME_OSDCOLOR (6'h3c)
|
| 46 |
+
`endif
|
| 47 |
+
`endif
|
| 48 |
+
|
| 49 |
+
localparam [9:0] OSD_WIDTH = 10'd256;
|
| 50 |
+
localparam [9:0] OSD_HEIGHT = 10'd128;
|
| 51 |
+
|
| 52 |
+
// *********************************************************************************
|
| 53 |
+
// spi client
|
| 54 |
+
// *********************************************************************************
|
| 55 |
+
|
| 56 |
+
// this core supports only the display related OSD commands
|
| 57 |
+
// of the minimig
|
| 58 |
+
reg osd_enable=1'b0;
|
| 59 |
+
wire osd_enable_sys;
|
| 60 |
+
|
| 61 |
+
(* ramstyle = "no_rw_check" *) reg [7:0] osd_buffer[2047:0]; // the OSD buffer itself
|
| 62 |
+
always @(posedge clk_sys)
|
| 63 |
+
osd_shown <= osd_enable_sys;
|
| 64 |
+
|
| 65 |
+
jtframe_sync u_sync_sys(
|
| 66 |
+
.clk_in ( SPI_SCK ),
|
| 67 |
+
.clk_out( clk_sys ),
|
| 68 |
+
.raw ( osd_enable ),
|
| 69 |
+
.sync ( osd_enable_sys )
|
| 70 |
+
);
|
| 71 |
+
|
| 72 |
+
|
| 73 |
+
`ifdef SIMULATION
|
| 74 |
+
initial begin:clear_buffer
|
| 75 |
+
integer cnt;
|
| 76 |
+
for( cnt=0; cnt<2048; cnt=cnt+1 )
|
| 77 |
+
osd_buffer[cnt] = 8'hAA;
|
| 78 |
+
end
|
| 79 |
+
`endif
|
| 80 |
+
|
| 81 |
+
// the OSD has its own SPI interface to the io controller
|
| 82 |
+
always@(posedge SPI_SCK, posedge SPI_SS3) begin: io_ctrl
|
| 83 |
+
|
| 84 |
+
reg [4:0] cnt;
|
| 85 |
+
reg [10:0] bcnt;
|
| 86 |
+
reg [7:0] sbuf;
|
| 87 |
+
reg [7:0] cmd;
|
| 88 |
+
if(SPI_SS3) begin
|
| 89 |
+
cnt <= 0;
|
| 90 |
+
bcnt <= 0;
|
| 91 |
+
end else begin
|
| 92 |
+
sbuf <= {sbuf[6:0], SPI_DI};
|
| 93 |
+
|
| 94 |
+
// 0:7 is command, rest payload
|
| 95 |
+
if(cnt < 15) cnt <= cnt + 1'd1;
|
| 96 |
+
else cnt <= 8;
|
| 97 |
+
|
| 98 |
+
if(cnt == 7) begin
|
| 99 |
+
cmd <= {sbuf[6:0], SPI_DI};
|
| 100 |
+
|
| 101 |
+
// lower three command bits are line address
|
| 102 |
+
bcnt <= {sbuf[1:0], SPI_DI, 8'h00};
|
| 103 |
+
|
| 104 |
+
// command 0x40: OSDCMDENABLE, OSDCMDDISABLE
|
| 105 |
+
if(sbuf[6:3] == 4'b0100) osd_enable <= SPI_DI;
|
| 106 |
+
end
|
| 107 |
+
|
| 108 |
+
// command 0x20: OSDCMDWRITE
|
| 109 |
+
if((cmd[7:3] == 5'b00100) && (cnt == 15)) begin
|
| 110 |
+
osd_buffer[bcnt] <= {sbuf[6:0], SPI_DI};
|
| 111 |
+
bcnt <= bcnt + 1'd1;
|
| 112 |
+
end
|
| 113 |
+
end
|
| 114 |
+
end
|
| 115 |
+
|
| 116 |
+
// *********************************************************************************
|
| 117 |
+
// video timing and sync polarity anaylsis
|
| 118 |
+
// *********************************************************************************
|
| 119 |
+
|
| 120 |
+
// horizontal counter
|
| 121 |
+
reg [9:0] h_cnt;
|
| 122 |
+
reg [9:0] hs_low, hs_high;
|
| 123 |
+
reg hs_pol;
|
| 124 |
+
reg [9:0] dsp_width;
|
| 125 |
+
|
| 126 |
+
// vertical counter
|
| 127 |
+
reg [9:0] v_cnt;
|
| 128 |
+
reg [9:0] vs_low, vs_high;
|
| 129 |
+
reg vs_pol;
|
| 130 |
+
reg [9:0] dsp_height;
|
| 131 |
+
|
| 132 |
+
reg doublescan;
|
| 133 |
+
|
| 134 |
+
|
| 135 |
+
reg ce_pix;
|
| 136 |
+
always @(negedge clk_sys) begin: horizontal_counter
|
| 137 |
+
integer cnt;
|
| 138 |
+
integer pixsz, pixcnt;
|
| 139 |
+
reg hs;
|
| 140 |
+
|
| 141 |
+
cnt <= cnt + 1;
|
| 142 |
+
hs <= HSync;
|
| 143 |
+
|
| 144 |
+
pixcnt <= pixcnt + 1;
|
| 145 |
+
if(pixcnt == pixsz) pixcnt <= 0;
|
| 146 |
+
ce_pix <= pixcnt==0;
|
| 147 |
+
|
| 148 |
+
if(hs && ~HSync) begin
|
| 149 |
+
cnt <= 0;
|
| 150 |
+
pixsz <= (cnt >> 9) - 1;
|
| 151 |
+
pixcnt <= 0;
|
| 152 |
+
ce_pix <= 1;
|
| 153 |
+
end
|
| 154 |
+
end
|
| 155 |
+
|
| 156 |
+
always @(posedge clk_sys) begin
|
| 157 |
+
hs_pol <= hs_high < hs_low;
|
| 158 |
+
dsp_width <= hs_pol ? hs_low : hs_high;
|
| 159 |
+
vs_pol <= vs_high < vs_low;
|
| 160 |
+
dsp_height <= vs_pol ? vs_low : vs_high;
|
| 161 |
+
doublescan <= dsp_height>350;
|
| 162 |
+
end
|
| 163 |
+
|
| 164 |
+
always @(posedge clk_sys) begin: sync
|
| 165 |
+
reg hsD, hsD2;
|
| 166 |
+
reg vsD, vsD2;
|
| 167 |
+
|
| 168 |
+
if(ce_pix) begin
|
| 169 |
+
// bring hsync into local clock domain
|
| 170 |
+
hsD <= HSync;
|
| 171 |
+
hsD2 <= hsD;
|
| 172 |
+
|
| 173 |
+
// falling edge of HSync
|
| 174 |
+
if(!hsD && hsD2) begin
|
| 175 |
+
h_cnt <= 0;
|
| 176 |
+
hs_high <= h_cnt;
|
| 177 |
+
end
|
| 178 |
+
|
| 179 |
+
// rising edge of HSync
|
| 180 |
+
else if(hsD && !hsD2) begin
|
| 181 |
+
h_cnt <= 0;
|
| 182 |
+
hs_low <= h_cnt;
|
| 183 |
+
v_cnt <= v_cnt + 1'd1;
|
| 184 |
+
end else begin
|
| 185 |
+
h_cnt <= h_cnt + 1'd1;
|
| 186 |
+
end
|
| 187 |
+
|
| 188 |
+
vsD <= VSync;
|
| 189 |
+
vsD2 <= vsD;
|
| 190 |
+
|
| 191 |
+
// falling edge of VSync
|
| 192 |
+
if(!vsD && vsD2) begin
|
| 193 |
+
v_cnt <= 0;
|
| 194 |
+
vs_high <= v_cnt;
|
| 195 |
+
end
|
| 196 |
+
|
| 197 |
+
// rising edge of VSync
|
| 198 |
+
else if(vsD && !vsD2) begin
|
| 199 |
+
v_cnt <= 0;
|
| 200 |
+
vs_low <= v_cnt;
|
| 201 |
+
end
|
| 202 |
+
end
|
| 203 |
+
end
|
| 204 |
+
|
| 205 |
+
// area in which OSD is being displayed
|
| 206 |
+
reg [9:0] h_osd_start;
|
| 207 |
+
reg [9:0] h_osd_end;
|
| 208 |
+
reg [9:0] v_osd_start;
|
| 209 |
+
reg [9:0] v_osd_end;
|
| 210 |
+
|
| 211 |
+
always @(posedge clk_sys) begin
|
| 212 |
+
h_osd_start <= ((dsp_width - OSD_WIDTH)>> 1) + OSD_X_OFFSET;
|
| 213 |
+
h_osd_end <= h_osd_start + OSD_WIDTH;
|
| 214 |
+
v_osd_start <= ((dsp_height- (OSD_HEIGHT<<doublescan))>> 1) + OSD_Y_OFFSET;
|
| 215 |
+
v_osd_end <= v_osd_start + (OSD_HEIGHT<<doublescan);
|
| 216 |
+
end
|
| 217 |
+
|
| 218 |
+
wire [9:0] osd_hcnt = h_cnt - h_osd_start;
|
| 219 |
+
wire [9:0] osd_vcnt = v_cnt - v_osd_start;
|
| 220 |
+
wire [9:0] osd_hcnt_next = osd_hcnt + 10'd1; // one pixel offset for osd pixel
|
| 221 |
+
wire [9:0] osd_hcnt_next2 = osd_hcnt + 10'd2; // two pixel offset for osd byte address register
|
| 222 |
+
reg osd_de;
|
| 223 |
+
|
| 224 |
+
reg [10:0] osd_buffer_addr;
|
| 225 |
+
wire [7:0] osd_byte = osd_buffer[osd_buffer_addr];
|
| 226 |
+
reg osd_pixel;
|
| 227 |
+
|
| 228 |
+
`ifdef SIMULATION
|
| 229 |
+
`ifndef JTFRAME_OSD_NOLOGO
|
| 230 |
+
// Disable OSD background for simulation
|
| 231 |
+
`define JTFRAME_OSD_NOLOGO
|
| 232 |
+
`endif
|
| 233 |
+
`endif
|
| 234 |
+
|
| 235 |
+
`ifndef JTFRAME_OSD_NOLOGO
|
| 236 |
+
reg [7:0] back_buffer[8*256];
|
| 237 |
+
wire [7:0] back_byte = back_buffer[osd_buffer_addr];
|
| 238 |
+
reg back_pixel;
|
| 239 |
+
`else
|
| 240 |
+
wire back_pixel = 1'b1;
|
| 241 |
+
`endif
|
| 242 |
+
|
| 243 |
+
always @(posedge clk_sys) begin
|
| 244 |
+
if (ce_pix) begin
|
| 245 |
+
osd_buffer_addr <= rotate[0] ? {rotate[1] ? ~osd_hcnt_next2[7:5] : osd_hcnt_next2[7:5],
|
| 246 |
+
rotate[1] ? (doublescan ? osd_vcnt[7:0] : {osd_vcnt[6:0], 1'b0}) :
|
| 247 |
+
(doublescan ? ~osd_vcnt[7:0] : ~{osd_vcnt[6:0], 1'b0})} :
|
| 248 |
+
// no rotation
|
| 249 |
+
{doublescan ? osd_vcnt[7:5] : osd_vcnt[6:4], osd_hcnt_next2[7:0]};
|
| 250 |
+
|
| 251 |
+
osd_pixel <= rotate[0] ? osd_byte[rotate[1] ? ~osd_hcnt_next[4:2] : osd_hcnt_next[4:2]] :
|
| 252 |
+
osd_byte[doublescan ? osd_vcnt[4:2] : osd_vcnt[3:1]];
|
| 253 |
+
`ifndef JTFRAME_OSD_NOLOGO
|
| 254 |
+
back_pixel <= rotate[0] ?
|
| 255 |
+
back_byte[rotate[1] ? ~osd_hcnt_next[4:2] : osd_hcnt_next[4:2]] :
|
| 256 |
+
// no rotation:
|
| 257 |
+
back_byte[doublescan ? osd_vcnt[4:2] : osd_vcnt[3:1]];
|
| 258 |
+
`endif
|
| 259 |
+
|
| 260 |
+
`ifdef SIMULATE_OSD
|
| 261 |
+
osd_de <=
|
| 262 |
+
`else
|
| 263 |
+
osd_de <= osd_enable_sys &&
|
| 264 |
+
`endif
|
| 265 |
+
(HSync != hs_pol) && ((h_cnt + 1'd1) >= h_osd_start) && ((h_cnt + 1'd1) < h_osd_end) &&
|
| 266 |
+
(VSync != vs_pol) && (v_cnt >= v_osd_start) && (v_cnt < v_osd_end);
|
| 267 |
+
|
| 268 |
+
end
|
| 269 |
+
|
| 270 |
+
R_out <= !osd_de ? R_in : { {2{osd_pixel}}, OSD_COLOR[5:4]^{1'b0,back_pixel}, R_in[OSD_DW-1:4]};
|
| 271 |
+
G_out <= !osd_de ? G_in : { {2{osd_pixel}}, OSD_COLOR[3:2]^{1'b0,back_pixel}, G_in[OSD_DW-1:4]};
|
| 272 |
+
B_out <= !osd_de ? B_in : { {2{osd_pixel}}, OSD_COLOR[1:0]^{1'b0,back_pixel}, B_in[OSD_DW-1:4]};
|
| 273 |
+
HSync_out <= HSync;
|
| 274 |
+
VSync_out <= VSync;
|
| 275 |
+
DE_out <= DE;
|
| 276 |
+
end
|
| 277 |
+
|
| 278 |
+
`ifndef JTFRAME_OSD_NOLOGO
|
| 279 |
+
initial begin
|
| 280 |
+
back_buffer = '{ 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00,
|
| 281 |
+
8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00,
|
| 282 |
+
8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00,
|
| 283 |
+
8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00,
|
| 284 |
+
8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00,
|
| 285 |
+
8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00,
|
| 286 |
+
8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00,
|
| 287 |
+
8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00,
|
| 288 |
+
8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'hC0, 8'hF0, 8'hF8, 8'hFC, 8'hFC, 8'hFC,
|
| 289 |
+
8'hFC, 8'hFC, 8'hFC, 8'hFC, 8'hFC, 8'hFC, 8'hFC, 8'hFC, 8'hFC, 8'hFC, 8'hFC, 8'hFC, 8'hFC, 8'hFC, 8'hFC, 8'hFC,
|
| 290 |
+
8'hFC, 8'hFC, 8'hFC, 8'hFC, 8'hFC, 8'hFC, 8'hFC, 8'hFC, 8'hFC, 8'hF0, 8'hF0, 8'hF0, 8'hC0, 8'hC0, 8'hC0, 8'hC0,
|
| 291 |
+
8'hC0, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00,
|
| 292 |
+
8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00,
|
| 293 |
+
8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00,
|
| 294 |
+
8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00,
|
| 295 |
+
8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00,
|
| 296 |
+
8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00,
|
| 297 |
+
8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00,
|
| 298 |
+
8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00,
|
| 299 |
+
8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00,
|
| 300 |
+
8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00,
|
| 301 |
+
8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00,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F8, 8'hF8, 8'hF8, 8'hF8, 8'hF8, 8'hF8, 8'hF8, 8'hF8, 8'hF8, 8'hF8, 8'hF8, 8'hF8, 8'hF8, 8'hF8, 8'hF8, 8'hF8,
|
| 311 |
+
8'hF8, 8'hF8, 8'hF8, 8'hF8, 8'hF8, 8'hF8, 8'hF8, 8'hF8, 8'hF8, 8'hF8, 8'hF8, 8'hF8, 8'hF8, 8'hF8, 8'hC8, 8'hC0,
|
| 312 |
+
8'hC0, 8'h80, 8'h80, 8'h80, 8'h80, 8'h80, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00,
|
| 313 |
+
8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00,
|
| 314 |
+
8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00,
|
| 315 |
+
8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00,
|
| 316 |
+
8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00,
|
| 317 |
+
8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00,
|
| 318 |
+
8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h80,
|
| 319 |
+
8'hE0, 8'hF8, 8'hFE, 8'hFF, 8'hFF, 8'hFF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F, 8'hFF, 8'hFF, 8'hFF,
|
| 328 |
+
8'hFF, 8'hFF, 8'h3F, 8'h0F, 8'h07, 8'h01, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00,
|
| 329 |
+
8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00,
|
| 330 |
+
8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00,
|
| 331 |
+
8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00,
|
| 332 |
+
8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00,
|
| 333 |
+
8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00,
|
| 334 |
+
8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h01,
|
| 335 |
+
8'h01, 8'h01, 8'h01, 8'h05, 8'h07, 8'h07, 8'h37, 8'h3F, 8'h3F, 8'h3F, 8'h3F, 8'h3F, 8'h3F, 8'hBF, 8'hFF, 8'hFF,
|
| 336 |
+
8'hFF, 8'hFF, 8'hFF, 8'hFF, 8'hFF, 8'hFF, 8'hFF, 8'hFF, 8'hFF, 8'hFF, 8'hFF, 8'hFF, 8'hFF, 8'hFF, 8'hFF, 8'hFF,
|
| 337 |
+
8'hFF, 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'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00,
|
| 355 |
+
8'h00, 8'h00, 8'h00, 8'h80, 8'hE0, 8'hF8, 8'hFC, 8'hFF, 8'hFF, 8'hFF, 8'hFF, 8'hFF, 8'hFF, 8'hFF, 8'hFF, 8'hFF,
|
| 356 |
+
8'hFF, 8'hFF, 8'hFF, 8'hFF, 8'hFF, 8'hFF, 8'hFF, 8'hFF, 8'hFF, 8'hFF, 8'hFF, 8'hFF, 8'hFF, 8'hFF, 8'hFF, 8'hFF,
|
| 357 |
+
8'hFF, 8'hFF, 8'hFF, 8'hFF, 8'hFF, 8'hFF, 8'hFF, 8'hFF, 8'hFF, 8'hFF, 8'h7F, 8'h1F, 8'h07, 8'h01, 8'h00, 8'h00,
|
| 358 |
+
8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00,
|
| 359 |
+
8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00,
|
| 360 |
+
8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00,
|
| 361 |
+
8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00,
|
| 362 |
+
8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00,
|
| 363 |
+
8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h3F, 8'h7F, 8'hFF, 8'hFF, 8'hFF, 8'hFF, 8'hFF, 8'hFF,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8'hFF, 8'hFF, 8'hFF, 8'hFF, 8'hFF, 8'hFF, 8'hFF, 8'hFF, 8'hFF, 8'hFF,
|
| 373 |
+
8'hFF, 8'hFF, 8'hFF, 8'hFF, 8'hFF, 8'hFF, 8'h3F, 8'h0F, 8'h03, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00,
|
| 374 |
+
8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00,
|
| 375 |
+
8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00,
|
| 376 |
+
8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00,
|
| 377 |
+
8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00,
|
| 378 |
+
8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00,
|
| 379 |
+
8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h01, 8'h03, 8'h03, 8'h07, 8'h0F, 8'h0F, 8'h1F, 8'h1F,
|
| 380 |
+
8'h3F, 8'h3F, 8'h7F, 8'hFF, 8'hFF, 8'hFF, 8'hFF, 8'hFF, 8'hFF, 8'hFF, 8'hFF, 8'hFF, 8'hFF, 8'hFF, 8'hFF, 8'hFF,
|
| 381 |
+
8'hFF, 8'hFF, 8'hFF, 8'hFF, 8'hFF, 8'hFF, 8'hFF, 8'hFF, 8'hFF, 8'hFF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, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00,
|
| 391 |
+
8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00,
|
| 392 |
+
8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00,
|
| 393 |
+
8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00,
|
| 394 |
+
8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00,
|
| 395 |
+
8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00,
|
| 396 |
+
8'h00, 8'h00, 8'h00, 8'h00, 8'h01, 8'h01, 8'h03, 8'h03, 8'h03, 8'h07, 8'h07, 8'h07, 8'h0F, 8'h0F, 8'h0F, 8'h0F,
|
| 397 |
+
8'h0F, 8'h1F, 8'h1F, 8'h1F, 8'h1F, 8'h1F, 8'h1F, 8'h1F, 8'h1F, 8'h1F, 8'h1F, 8'h1F, 8'h1F, 8'h1F, 8'h1F, 8'h1F,
|
| 398 |
+
8'h1F, 8'h1F, 8'h1F, 8'h1F, 8'h1F, 8'h1F, 8'h1F, 8'h1F, 8'h1F, 8'h1F, 8'h1F, 8'h1F, 8'h1F, 8'h1F, 8'h1F, 8'h1F,
|
| 399 |
+
8'h1F, 8'h1F, 8'h1F, 8'h1F, 8'h1F, 8'h1F, 8'h1F, 8'h1F, 8'h1F, 8'h1F, 8'h0F, 8'h0F, 8'h0F, 8'h0F, 8'h0F, 8'h0F,
|
| 400 |
+
8'h07, 8'h07, 8'h07, 8'h07, 8'h03, 8'h03, 8'h03, 8'h01, 8'h01, 8'h01, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00,
|
| 401 |
+
8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00,
|
| 402 |
+
8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h01, 8'h01, 8'h01, 8'h01, 8'h01, 8'h07,
|
| 403 |
+
8'h07, 8'h07, 8'h1F, 8'h1F, 8'h1F, 8'h1F, 8'h1F, 8'h1F, 8'h1F, 8'h1F, 8'h1F, 8'h1F, 8'h1F, 8'h1F, 8'h1F, 8'h1F,
|
| 404 |
+
8'h1F, 8'h1F, 8'h1F, 8'h1F, 8'h1F, 8'h1F, 8'h1F, 8'h1F, 8'h1F, 8'h1F, 8'h1F, 8'h1F, 8'h1F, 8'h1F, 8'h1F, 8'h07,
|
| 405 |
+
8'h01, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00,
|
| 406 |
+
8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00,
|
| 407 |
+
8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00,
|
| 408 |
+
8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00 };
|
| 409 |
+
end
|
| 410 |
+
`endif
|
| 411 |
+
endmodule
|
snapshots/jotego_jtcores_pr1270/modules/jtframe/target/mist/hdl/pll6000/jtframe_pll6000.ppf
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?xml version="1.0" encoding="UTF-8" ?>
|
| 2 |
+
<!DOCTYPE pinplan>
|
| 3 |
+
<pinplan intended_family="Cyclone III" variation_name="jtframe_pll6000" megafunction_name="ALTPLL" specifies="all_ports">
|
| 4 |
+
<global>
|
| 5 |
+
<pin name="inclk0" direction="input" scope="external" source="clock" />
|
| 6 |
+
<pin name="c0" direction="output" scope="external" source="clock" />
|
| 7 |
+
<pin name="locked" direction="output" scope="external" />
|
| 8 |
+
|
| 9 |
+
</global>
|
| 10 |
+
</pinplan>
|
snapshots/jotego_jtcores_pr1270/modules/jtframe/target/mist/hdl/pll6000/jtframe_pll6000.qip
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
set_global_assignment -name IP_TOOL_NAME "ALTPLL"
|
| 2 |
+
set_global_assignment -name IP_TOOL_VERSION "13.1"
|
| 3 |
+
set_global_assignment -name VERILOG_FILE [file join $::quartus(qip_path) "jtframe_pll6000.v"]
|
| 4 |
+
set_global_assignment -name MISC_FILE [file join $::quartus(qip_path) "jtframe_pll6000_bb.v"]
|
| 5 |
+
set_global_assignment -name MISC_FILE [file join $::quartus(qip_path) "jtframe_pll6000.ppf"]
|
snapshots/jotego_jtcores_pr1270/modules/jtframe/target/mist/hdl/pll6000/jtframe_pll6000.v
ADDED
|
@@ -0,0 +1,309 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// megafunction wizard: %ALTPLL%
|
| 2 |
+
// GENERATION: STANDARD
|
| 3 |
+
// VERSION: WM1.0
|
| 4 |
+
// MODULE: altpll
|
| 5 |
+
|
| 6 |
+
// ============================================================
|
| 7 |
+
// File Name: jtframe_pll6000.v
|
| 8 |
+
// Megafunction Name(s):
|
| 9 |
+
// altpll
|
| 10 |
+
//
|
| 11 |
+
// Simulation Library Files(s):
|
| 12 |
+
// altera_mf
|
| 13 |
+
// ============================================================
|
| 14 |
+
// ************************************************************
|
| 15 |
+
// THIS IS A WIZARD-GENERATED FILE. DO NOT EDIT THIS FILE!
|
| 16 |
+
//
|
| 17 |
+
// 13.1.0 Build 162 10/23/2013 SJ Web Edition
|
| 18 |
+
// ************************************************************
|
| 19 |
+
|
| 20 |
+
|
| 21 |
+
//Copyright (C) 1991-2013 Altera Corporation
|
| 22 |
+
//Your use of Altera Corporation's design tools, logic functions
|
| 23 |
+
//and other software and tools, and its AMPP partner logic
|
| 24 |
+
//functions, and any output files from any of the foregoing
|
| 25 |
+
//(including device programming or simulation files), and any
|
| 26 |
+
//associated documentation or information are expressly subject
|
| 27 |
+
//to the terms and conditions of the Altera Program License
|
| 28 |
+
//Subscription Agreement, Altera MegaCore Function License
|
| 29 |
+
//Agreement, or other applicable license agreement, including,
|
| 30 |
+
//without limitation, that your use is for the sole purpose of
|
| 31 |
+
//programming logic devices manufactured by Altera and sold by
|
| 32 |
+
//Altera or its authorized distributors. Please refer to the
|
| 33 |
+
//applicable agreement for further details.
|
| 34 |
+
|
| 35 |
+
|
| 36 |
+
// synopsys translate_off
|
| 37 |
+
`timescale 1 ps / 1 ps
|
| 38 |
+
// synopsys translate_on
|
| 39 |
+
module jtframe_pll6000 (
|
| 40 |
+
inclk0,
|
| 41 |
+
c0,
|
| 42 |
+
locked);
|
| 43 |
+
|
| 44 |
+
input inclk0;
|
| 45 |
+
output c0;
|
| 46 |
+
output locked;
|
| 47 |
+
|
| 48 |
+
wire [4:0] sub_wire0;
|
| 49 |
+
wire sub_wire2;
|
| 50 |
+
wire [0:0] sub_wire5 = 1'h0;
|
| 51 |
+
wire [0:0] sub_wire1 = sub_wire0[0:0];
|
| 52 |
+
wire c0 = sub_wire1;
|
| 53 |
+
wire locked = sub_wire2;
|
| 54 |
+
wire sub_wire3 = inclk0;
|
| 55 |
+
wire [1:0] sub_wire4 = {sub_wire5, sub_wire3};
|
| 56 |
+
|
| 57 |
+
altpll altpll_component (
|
| 58 |
+
.inclk (sub_wire4),
|
| 59 |
+
.clk (sub_wire0),
|
| 60 |
+
.locked (sub_wire2),
|
| 61 |
+
.activeclock (),
|
| 62 |
+
.areset (1'b0),
|
| 63 |
+
.clkbad (),
|
| 64 |
+
.clkena ({6{1'b1}}),
|
| 65 |
+
.clkloss (),
|
| 66 |
+
.clkswitch (1'b0),
|
| 67 |
+
.configupdate (1'b0),
|
| 68 |
+
.enable0 (),
|
| 69 |
+
.enable1 (),
|
| 70 |
+
.extclk (),
|
| 71 |
+
.extclkena ({4{1'b1}}),
|
| 72 |
+
.fbin (1'b1),
|
| 73 |
+
.fbmimicbidir (),
|
| 74 |
+
.fbout (),
|
| 75 |
+
.fref (),
|
| 76 |
+
.icdrclk (),
|
| 77 |
+
.pfdena (1'b1),
|
| 78 |
+
.phasecounterselect ({4{1'b1}}),
|
| 79 |
+
.phasedone (),
|
| 80 |
+
.phasestep (1'b1),
|
| 81 |
+
.phaseupdown (1'b1),
|
| 82 |
+
.pllena (1'b1),
|
| 83 |
+
.scanaclr (1'b0),
|
| 84 |
+
.scanclk (1'b0),
|
| 85 |
+
.scanclkena (1'b1),
|
| 86 |
+
.scandata (1'b0),
|
| 87 |
+
.scandataout (),
|
| 88 |
+
.scandone (),
|
| 89 |
+
.scanread (1'b0),
|
| 90 |
+
.scanwrite (1'b0),
|
| 91 |
+
.sclkout0 (),
|
| 92 |
+
.sclkout1 (),
|
| 93 |
+
.vcooverrange (),
|
| 94 |
+
.vcounderrange ());
|
| 95 |
+
defparam
|
| 96 |
+
altpll_component.bandwidth_type = "AUTO",
|
| 97 |
+
altpll_component.clk0_divide_by = 9,
|
| 98 |
+
altpll_component.clk0_duty_cycle = 50,
|
| 99 |
+
altpll_component.clk0_multiply_by = 16,
|
| 100 |
+
altpll_component.clk0_phase_shift = "0",
|
| 101 |
+
altpll_component.compensate_clock = "CLK0",
|
| 102 |
+
altpll_component.inclk0_input_frequency = 37037,
|
| 103 |
+
altpll_component.intended_device_family = "Cyclone III",
|
| 104 |
+
altpll_component.lpm_hint = "CBX_MODULE_PREFIX=jtframe_pll6000",
|
| 105 |
+
altpll_component.lpm_type = "altpll",
|
| 106 |
+
altpll_component.operation_mode = "NORMAL",
|
| 107 |
+
altpll_component.pll_type = "AUTO",
|
| 108 |
+
altpll_component.port_activeclock = "PORT_UNUSED",
|
| 109 |
+
altpll_component.port_areset = "PORT_UNUSED",
|
| 110 |
+
altpll_component.port_clkbad0 = "PORT_UNUSED",
|
| 111 |
+
altpll_component.port_clkbad1 = "PORT_UNUSED",
|
| 112 |
+
altpll_component.port_clkloss = "PORT_UNUSED",
|
| 113 |
+
altpll_component.port_clkswitch = "PORT_UNUSED",
|
| 114 |
+
altpll_component.port_configupdate = "PORT_UNUSED",
|
| 115 |
+
altpll_component.port_fbin = "PORT_UNUSED",
|
| 116 |
+
altpll_component.port_inclk0 = "PORT_USED",
|
| 117 |
+
altpll_component.port_inclk1 = "PORT_UNUSED",
|
| 118 |
+
altpll_component.port_locked = "PORT_USED",
|
| 119 |
+
altpll_component.port_pfdena = "PORT_UNUSED",
|
| 120 |
+
altpll_component.port_phasecounterselect = "PORT_UNUSED",
|
| 121 |
+
altpll_component.port_phasedone = "PORT_UNUSED",
|
| 122 |
+
altpll_component.port_phasestep = "PORT_UNUSED",
|
| 123 |
+
altpll_component.port_phaseupdown = "PORT_UNUSED",
|
| 124 |
+
altpll_component.port_pllena = "PORT_UNUSED",
|
| 125 |
+
altpll_component.port_scanaclr = "PORT_UNUSED",
|
| 126 |
+
altpll_component.port_scanclk = "PORT_UNUSED",
|
| 127 |
+
altpll_component.port_scanclkena = "PORT_UNUSED",
|
| 128 |
+
altpll_component.port_scandata = "PORT_UNUSED",
|
| 129 |
+
altpll_component.port_scandataout = "PORT_UNUSED",
|
| 130 |
+
altpll_component.port_scandone = "PORT_UNUSED",
|
| 131 |
+
altpll_component.port_scanread = "PORT_UNUSED",
|
| 132 |
+
altpll_component.port_scanwrite = "PORT_UNUSED",
|
| 133 |
+
altpll_component.port_clk0 = "PORT_USED",
|
| 134 |
+
altpll_component.port_clk1 = "PORT_UNUSED",
|
| 135 |
+
altpll_component.port_clk2 = "PORT_UNUSED",
|
| 136 |
+
altpll_component.port_clk3 = "PORT_UNUSED",
|
| 137 |
+
altpll_component.port_clk4 = "PORT_UNUSED",
|
| 138 |
+
altpll_component.port_clk5 = "PORT_UNUSED",
|
| 139 |
+
altpll_component.port_clkena0 = "PORT_UNUSED",
|
| 140 |
+
altpll_component.port_clkena1 = "PORT_UNUSED",
|
| 141 |
+
altpll_component.port_clkena2 = "PORT_UNUSED",
|
| 142 |
+
altpll_component.port_clkena3 = "PORT_UNUSED",
|
| 143 |
+
altpll_component.port_clkena4 = "PORT_UNUSED",
|
| 144 |
+
altpll_component.port_clkena5 = "PORT_UNUSED",
|
| 145 |
+
altpll_component.port_extclk0 = "PORT_UNUSED",
|
| 146 |
+
altpll_component.port_extclk1 = "PORT_UNUSED",
|
| 147 |
+
altpll_component.port_extclk2 = "PORT_UNUSED",
|
| 148 |
+
altpll_component.port_extclk3 = "PORT_UNUSED",
|
| 149 |
+
altpll_component.self_reset_on_loss_lock = "ON",
|
| 150 |
+
altpll_component.width_clock = 5;
|
| 151 |
+
|
| 152 |
+
|
| 153 |
+
endmodule
|
| 154 |
+
|
| 155 |
+
// ============================================================
|
| 156 |
+
// CNX file retrieval info
|
| 157 |
+
// ============================================================
|
| 158 |
+
// Retrieval info: PRIVATE: ACTIVECLK_CHECK STRING "0"
|
| 159 |
+
// Retrieval info: PRIVATE: BANDWIDTH STRING "1.000"
|
| 160 |
+
// Retrieval info: PRIVATE: BANDWIDTH_FEATURE_ENABLED STRING "1"
|
| 161 |
+
// Retrieval info: PRIVATE: BANDWIDTH_FREQ_UNIT STRING "MHz"
|
| 162 |
+
// Retrieval info: PRIVATE: BANDWIDTH_PRESET STRING "Low"
|
| 163 |
+
// Retrieval info: PRIVATE: BANDWIDTH_USE_AUTO STRING "1"
|
| 164 |
+
// Retrieval info: PRIVATE: BANDWIDTH_USE_PRESET STRING "0"
|
| 165 |
+
// Retrieval info: PRIVATE: CLKBAD_SWITCHOVER_CHECK STRING "0"
|
| 166 |
+
// Retrieval info: PRIVATE: CLKLOSS_CHECK STRING "0"
|
| 167 |
+
// Retrieval info: PRIVATE: CLKSWITCH_CHECK STRING "0"
|
| 168 |
+
// Retrieval info: PRIVATE: CNX_NO_COMPENSATE_RADIO STRING "0"
|
| 169 |
+
// Retrieval info: PRIVATE: CREATE_CLKBAD_CHECK STRING "0"
|
| 170 |
+
// Retrieval info: PRIVATE: CREATE_INCLK1_CHECK STRING "0"
|
| 171 |
+
// Retrieval info: PRIVATE: CUR_DEDICATED_CLK STRING "c0"
|
| 172 |
+
// Retrieval info: PRIVATE: CUR_FBIN_CLK STRING "c0"
|
| 173 |
+
// Retrieval info: PRIVATE: DEVICE_SPEED_GRADE STRING "8"
|
| 174 |
+
// Retrieval info: PRIVATE: DIV_FACTOR0 NUMERIC "1"
|
| 175 |
+
// Retrieval info: PRIVATE: DUTY_CYCLE0 STRING "50.00000000"
|
| 176 |
+
// Retrieval info: PRIVATE: EFF_OUTPUT_FREQ_VALUE0 STRING "48.000000"
|
| 177 |
+
// Retrieval info: PRIVATE: EXPLICIT_SWITCHOVER_COUNTER STRING "0"
|
| 178 |
+
// Retrieval info: PRIVATE: EXT_FEEDBACK_RADIO STRING "0"
|
| 179 |
+
// Retrieval info: PRIVATE: GLOCKED_COUNTER_EDIT_CHANGED STRING "1"
|
| 180 |
+
// Retrieval info: PRIVATE: GLOCKED_FEATURE_ENABLED STRING "0"
|
| 181 |
+
// Retrieval info: PRIVATE: GLOCKED_MODE_CHECK STRING "0"
|
| 182 |
+
// Retrieval info: PRIVATE: GLOCK_COUNTER_EDIT NUMERIC "1048575"
|
| 183 |
+
// Retrieval info: PRIVATE: HAS_MANUAL_SWITCHOVER STRING "1"
|
| 184 |
+
// Retrieval info: PRIVATE: INCLK0_FREQ_EDIT STRING "27.000"
|
| 185 |
+
// Retrieval info: PRIVATE: INCLK0_FREQ_UNIT_COMBO STRING "MHz"
|
| 186 |
+
// Retrieval info: PRIVATE: INCLK1_FREQ_EDIT STRING "100.000"
|
| 187 |
+
// Retrieval info: PRIVATE: INCLK1_FREQ_EDIT_CHANGED STRING "1"
|
| 188 |
+
// Retrieval info: PRIVATE: INCLK1_FREQ_UNIT_CHANGED STRING "1"
|
| 189 |
+
// Retrieval info: PRIVATE: INCLK1_FREQ_UNIT_COMBO STRING "MHz"
|
| 190 |
+
// Retrieval info: PRIVATE: INTENDED_DEVICE_FAMILY STRING "Cyclone III"
|
| 191 |
+
// Retrieval info: PRIVATE: INT_FEEDBACK__MODE_RADIO STRING "1"
|
| 192 |
+
// Retrieval info: PRIVATE: LOCKED_OUTPUT_CHECK STRING "1"
|
| 193 |
+
// Retrieval info: PRIVATE: LONG_SCAN_RADIO STRING "1"
|
| 194 |
+
// Retrieval info: PRIVATE: LVDS_MODE_DATA_RATE STRING "Not Available"
|
| 195 |
+
// Retrieval info: PRIVATE: LVDS_MODE_DATA_RATE_DIRTY NUMERIC "0"
|
| 196 |
+
// Retrieval info: PRIVATE: LVDS_PHASE_SHIFT_UNIT0 STRING "deg"
|
| 197 |
+
// Retrieval info: PRIVATE: MIG_DEVICE_SPEED_GRADE STRING "Any"
|
| 198 |
+
// Retrieval info: PRIVATE: MIRROR_CLK0 STRING "0"
|
| 199 |
+
// Retrieval info: PRIVATE: MULT_FACTOR0 NUMERIC "1"
|
| 200 |
+
// Retrieval info: PRIVATE: NORMAL_MODE_RADIO STRING "1"
|
| 201 |
+
// Retrieval info: PRIVATE: OUTPUT_FREQ0 STRING "48.00000000"
|
| 202 |
+
// Retrieval info: PRIVATE: OUTPUT_FREQ_MODE0 STRING "1"
|
| 203 |
+
// Retrieval info: PRIVATE: OUTPUT_FREQ_UNIT0 STRING "MHz"
|
| 204 |
+
// Retrieval info: PRIVATE: PHASE_RECONFIG_FEATURE_ENABLED STRING "1"
|
| 205 |
+
// Retrieval info: PRIVATE: PHASE_RECONFIG_INPUTS_CHECK STRING "0"
|
| 206 |
+
// Retrieval info: PRIVATE: PHASE_SHIFT0 STRING "0.00000000"
|
| 207 |
+
// Retrieval info: PRIVATE: PHASE_SHIFT_STEP_ENABLED_CHECK STRING "0"
|
| 208 |
+
// Retrieval info: PRIVATE: PHASE_SHIFT_UNIT0 STRING "deg"
|
| 209 |
+
// Retrieval info: PRIVATE: PLL_ADVANCED_PARAM_CHECK STRING "0"
|
| 210 |
+
// Retrieval info: PRIVATE: PLL_ARESET_CHECK STRING "0"
|
| 211 |
+
// Retrieval info: PRIVATE: PLL_AUTOPLL_CHECK NUMERIC "1"
|
| 212 |
+
// Retrieval info: PRIVATE: PLL_ENHPLL_CHECK NUMERIC "0"
|
| 213 |
+
// Retrieval info: PRIVATE: PLL_FASTPLL_CHECK NUMERIC "0"
|
| 214 |
+
// Retrieval info: PRIVATE: PLL_FBMIMIC_CHECK STRING "0"
|
| 215 |
+
// Retrieval info: PRIVATE: PLL_LVDS_PLL_CHECK NUMERIC "0"
|
| 216 |
+
// Retrieval info: PRIVATE: PLL_PFDENA_CHECK STRING "0"
|
| 217 |
+
// Retrieval info: PRIVATE: PLL_TARGET_HARCOPY_CHECK NUMERIC "0"
|
| 218 |
+
// Retrieval info: PRIVATE: PRIMARY_CLK_COMBO STRING "inclk0"
|
| 219 |
+
// Retrieval info: PRIVATE: RECONFIG_FILE STRING "jtframe_pll6000.mif"
|
| 220 |
+
// Retrieval info: PRIVATE: SACN_INPUTS_CHECK STRING "0"
|
| 221 |
+
// Retrieval info: PRIVATE: SCAN_FEATURE_ENABLED STRING "1"
|
| 222 |
+
// Retrieval info: PRIVATE: SELF_RESET_LOCK_LOSS STRING "1"
|
| 223 |
+
// Retrieval info: PRIVATE: SHORT_SCAN_RADIO STRING "0"
|
| 224 |
+
// Retrieval info: PRIVATE: SPREAD_FEATURE_ENABLED STRING "0"
|
| 225 |
+
// Retrieval info: PRIVATE: SPREAD_FREQ STRING "50.000"
|
| 226 |
+
// Retrieval info: PRIVATE: SPREAD_FREQ_UNIT STRING "KHz"
|
| 227 |
+
// Retrieval info: PRIVATE: SPREAD_PERCENT STRING "0.500"
|
| 228 |
+
// Retrieval info: PRIVATE: SPREAD_USE STRING "0"
|
| 229 |
+
// Retrieval info: PRIVATE: SRC_SYNCH_COMP_RADIO STRING "0"
|
| 230 |
+
// Retrieval info: PRIVATE: STICKY_CLK0 STRING "1"
|
| 231 |
+
// Retrieval info: PRIVATE: SWITCHOVER_COUNT_EDIT NUMERIC "1"
|
| 232 |
+
// Retrieval info: PRIVATE: SWITCHOVER_FEATURE_ENABLED STRING "1"
|
| 233 |
+
// Retrieval info: PRIVATE: SYNTH_WRAPPER_GEN_POSTFIX STRING "0"
|
| 234 |
+
// Retrieval info: PRIVATE: USE_CLK0 STRING "1"
|
| 235 |
+
// Retrieval info: PRIVATE: USE_CLKENA0 STRING "0"
|
| 236 |
+
// Retrieval info: PRIVATE: USE_MIL_SPEED_GRADE NUMERIC "0"
|
| 237 |
+
// Retrieval info: PRIVATE: ZERO_DELAY_RADIO STRING "0"
|
| 238 |
+
// Retrieval info: LIBRARY: altera_mf altera_mf.altera_mf_components.all
|
| 239 |
+
// Retrieval info: CONSTANT: BANDWIDTH_TYPE STRING "AUTO"
|
| 240 |
+
// Retrieval info: CONSTANT: CLK0_DIVIDE_BY NUMERIC "9"
|
| 241 |
+
// Retrieval info: CONSTANT: CLK0_DUTY_CYCLE NUMERIC "50"
|
| 242 |
+
// Retrieval info: CONSTANT: CLK0_MULTIPLY_BY NUMERIC "16"
|
| 243 |
+
// Retrieval info: CONSTANT: CLK0_PHASE_SHIFT STRING "0"
|
| 244 |
+
// Retrieval info: CONSTANT: COMPENSATE_CLOCK STRING "CLK0"
|
| 245 |
+
// Retrieval info: CONSTANT: INCLK0_INPUT_FREQUENCY NUMERIC "37037"
|
| 246 |
+
// Retrieval info: CONSTANT: INTENDED_DEVICE_FAMILY STRING "Cyclone III"
|
| 247 |
+
// Retrieval info: CONSTANT: LPM_TYPE STRING "altpll"
|
| 248 |
+
// Retrieval info: CONSTANT: OPERATION_MODE STRING "NORMAL"
|
| 249 |
+
// Retrieval info: CONSTANT: PLL_TYPE STRING "AUTO"
|
| 250 |
+
// Retrieval info: CONSTANT: PORT_ACTIVECLOCK STRING "PORT_UNUSED"
|
| 251 |
+
// Retrieval info: CONSTANT: PORT_ARESET STRING "PORT_UNUSED"
|
| 252 |
+
// Retrieval info: CONSTANT: PORT_CLKBAD0 STRING "PORT_UNUSED"
|
| 253 |
+
// Retrieval info: CONSTANT: PORT_CLKBAD1 STRING "PORT_UNUSED"
|
| 254 |
+
// Retrieval info: CONSTANT: PORT_CLKLOSS STRING "PORT_UNUSED"
|
| 255 |
+
// Retrieval info: CONSTANT: PORT_CLKSWITCH STRING "PORT_UNUSED"
|
| 256 |
+
// Retrieval info: CONSTANT: PORT_CONFIGUPDATE STRING "PORT_UNUSED"
|
| 257 |
+
// Retrieval info: CONSTANT: PORT_FBIN STRING "PORT_UNUSED"
|
| 258 |
+
// Retrieval info: CONSTANT: PORT_INCLK0 STRING "PORT_USED"
|
| 259 |
+
// Retrieval info: CONSTANT: PORT_INCLK1 STRING "PORT_UNUSED"
|
| 260 |
+
// Retrieval info: CONSTANT: PORT_LOCKED STRING "PORT_USED"
|
| 261 |
+
// Retrieval info: CONSTANT: PORT_PFDENA STRING "PORT_UNUSED"
|
| 262 |
+
// Retrieval info: CONSTANT: PORT_PHASECOUNTERSELECT STRING "PORT_UNUSED"
|
| 263 |
+
// Retrieval info: CONSTANT: PORT_PHASEDONE STRING "PORT_UNUSED"
|
| 264 |
+
// Retrieval info: CONSTANT: PORT_PHASESTEP STRING "PORT_UNUSED"
|
| 265 |
+
// Retrieval info: CONSTANT: PORT_PHASEUPDOWN STRING "PORT_UNUSED"
|
| 266 |
+
// Retrieval info: CONSTANT: PORT_PLLENA STRING "PORT_UNUSED"
|
| 267 |
+
// Retrieval info: CONSTANT: PORT_SCANACLR STRING "PORT_UNUSED"
|
| 268 |
+
// Retrieval info: CONSTANT: PORT_SCANCLK STRING "PORT_UNUSED"
|
| 269 |
+
// Retrieval info: CONSTANT: PORT_SCANCLKENA STRING "PORT_UNUSED"
|
| 270 |
+
// Retrieval info: CONSTANT: PORT_SCANDATA STRING "PORT_UNUSED"
|
| 271 |
+
// Retrieval info: CONSTANT: PORT_SCANDATAOUT STRING "PORT_UNUSED"
|
| 272 |
+
// Retrieval info: CONSTANT: PORT_SCANDONE STRING "PORT_UNUSED"
|
| 273 |
+
// Retrieval info: CONSTANT: PORT_SCANREAD STRING "PORT_UNUSED"
|
| 274 |
+
// Retrieval info: CONSTANT: PORT_SCANWRITE STRING "PORT_UNUSED"
|
| 275 |
+
// Retrieval info: CONSTANT: PORT_clk0 STRING "PORT_USED"
|
| 276 |
+
// Retrieval info: CONSTANT: PORT_clk1 STRING "PORT_UNUSED"
|
| 277 |
+
// Retrieval info: CONSTANT: PORT_clk2 STRING "PORT_UNUSED"
|
| 278 |
+
// Retrieval info: CONSTANT: PORT_clk3 STRING "PORT_UNUSED"
|
| 279 |
+
// Retrieval info: CONSTANT: PORT_clk4 STRING "PORT_UNUSED"
|
| 280 |
+
// Retrieval info: CONSTANT: PORT_clk5 STRING "PORT_UNUSED"
|
| 281 |
+
// Retrieval info: CONSTANT: PORT_clkena0 STRING "PORT_UNUSED"
|
| 282 |
+
// Retrieval info: CONSTANT: PORT_clkena1 STRING "PORT_UNUSED"
|
| 283 |
+
// Retrieval info: CONSTANT: PORT_clkena2 STRING "PORT_UNUSED"
|
| 284 |
+
// Retrieval info: CONSTANT: PORT_clkena3 STRING "PORT_UNUSED"
|
| 285 |
+
// Retrieval info: CONSTANT: PORT_clkena4 STRING "PORT_UNUSED"
|
| 286 |
+
// Retrieval info: CONSTANT: PORT_clkena5 STRING "PORT_UNUSED"
|
| 287 |
+
// Retrieval info: CONSTANT: PORT_extclk0 STRING "PORT_UNUSED"
|
| 288 |
+
// Retrieval info: CONSTANT: PORT_extclk1 STRING "PORT_UNUSED"
|
| 289 |
+
// Retrieval info: CONSTANT: PORT_extclk2 STRING "PORT_UNUSED"
|
| 290 |
+
// Retrieval info: CONSTANT: PORT_extclk3 STRING "PORT_UNUSED"
|
| 291 |
+
// Retrieval info: CONSTANT: SELF_RESET_ON_LOSS_LOCK STRING "ON"
|
| 292 |
+
// Retrieval info: CONSTANT: WIDTH_CLOCK NUMERIC "5"
|
| 293 |
+
// Retrieval info: USED_PORT: @clk 0 0 5 0 OUTPUT_CLK_EXT VCC "@clk[4..0]"
|
| 294 |
+
// Retrieval info: USED_PORT: c0 0 0 0 0 OUTPUT_CLK_EXT VCC "c0"
|
| 295 |
+
// Retrieval info: USED_PORT: inclk0 0 0 0 0 INPUT_CLK_EXT GND "inclk0"
|
| 296 |
+
// Retrieval info: USED_PORT: locked 0 0 0 0 OUTPUT GND "locked"
|
| 297 |
+
// Retrieval info: CONNECT: @inclk 0 0 1 1 GND 0 0 0 0
|
| 298 |
+
// Retrieval info: CONNECT: @inclk 0 0 1 0 inclk0 0 0 0 0
|
| 299 |
+
// Retrieval info: CONNECT: c0 0 0 0 0 @clk 0 0 1 0
|
| 300 |
+
// Retrieval info: CONNECT: locked 0 0 0 0 @locked 0 0 0 0
|
| 301 |
+
// Retrieval info: GEN_FILE: TYPE_NORMAL jtframe_pll6000.v TRUE
|
| 302 |
+
// Retrieval info: GEN_FILE: TYPE_NORMAL jtframe_pll6000.ppf TRUE
|
| 303 |
+
// Retrieval info: GEN_FILE: TYPE_NORMAL jtframe_pll6000.inc FALSE
|
| 304 |
+
// Retrieval info: GEN_FILE: TYPE_NORMAL jtframe_pll6000.cmp FALSE
|
| 305 |
+
// Retrieval info: GEN_FILE: TYPE_NORMAL jtframe_pll6000.bsf FALSE
|
| 306 |
+
// Retrieval info: GEN_FILE: TYPE_NORMAL jtframe_pll6000_inst.v FALSE
|
| 307 |
+
// Retrieval info: GEN_FILE: TYPE_NORMAL jtframe_pll6000_bb.v TRUE
|
| 308 |
+
// Retrieval info: LIB_FILE: altera_mf
|
| 309 |
+
// Retrieval info: CBX_MODULE_PREFIX: ON
|
snapshots/jotego_jtcores_pr1270/modules/jtframe/target/mist/hdl/pll6000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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// megafunction wizard: %ALTPLL%VBB%
|
| 2 |
+
// GENERATION: STANDARD
|
| 3 |
+
// VERSION: WM1.0
|
| 4 |
+
// MODULE: altpll
|
| 5 |
+
|
| 6 |
+
// ============================================================
|
| 7 |
+
// File Name: jtframe_pll6000.v
|
| 8 |
+
// Megafunction Name(s):
|
| 9 |
+
// altpll
|
| 10 |
+
//
|
| 11 |
+
// Simulation Library Files(s):
|
| 12 |
+
// altera_mf
|
| 13 |
+
// ============================================================
|
| 14 |
+
// ************************************************************
|
| 15 |
+
// THIS IS A WIZARD-GENERATED FILE. DO NOT EDIT THIS FILE!
|
| 16 |
+
//
|
| 17 |
+
// 13.1.0 Build 162 10/23/2013 SJ Web Edition
|
| 18 |
+
// ************************************************************
|
| 19 |
+
|
| 20 |
+
//Copyright (C) 1991-2013 Altera Corporation
|
| 21 |
+
//Your use of Altera Corporation's design tools, logic functions
|
| 22 |
+
//and other software and tools, and its AMPP partner logic
|
| 23 |
+
//functions, and any output files from any of the foregoing
|
| 24 |
+
//(including device programming or simulation files), and any
|
| 25 |
+
//associated documentation or information are expressly subject
|
| 26 |
+
//to the terms and conditions of the Altera Program License
|
| 27 |
+
//Subscription Agreement, Altera MegaCore Function License
|
| 28 |
+
//Agreement, or other applicable license agreement, including,
|
| 29 |
+
//without limitation, that your use is for the sole purpose of
|
| 30 |
+
//programming logic devices manufactured by Altera and sold by
|
| 31 |
+
//Altera or its authorized distributors. Please refer to the
|
| 32 |
+
//applicable agreement for further details.
|
| 33 |
+
|
| 34 |
+
module jtframe_pll6000 (
|
| 35 |
+
inclk0,
|
| 36 |
+
c0,
|
| 37 |
+
locked);
|
| 38 |
+
|
| 39 |
+
input inclk0;
|
| 40 |
+
output c0;
|
| 41 |
+
output locked;
|
| 42 |
+
|
| 43 |
+
endmodule
|
| 44 |
+
|
| 45 |
+
// ============================================================
|
| 46 |
+
// CNX file retrieval info
|
| 47 |
+
// ============================================================
|
| 48 |
+
// Retrieval info: PRIVATE: ACTIVECLK_CHECK STRING "0"
|
| 49 |
+
// Retrieval info: PRIVATE: BANDWIDTH STRING "1.000"
|
| 50 |
+
// Retrieval info: PRIVATE: BANDWIDTH_FEATURE_ENABLED STRING "1"
|
| 51 |
+
// Retrieval info: PRIVATE: BANDWIDTH_FREQ_UNIT STRING "MHz"
|
| 52 |
+
// Retrieval info: PRIVATE: BANDWIDTH_PRESET STRING "Low"
|
| 53 |
+
// Retrieval info: PRIVATE: BANDWIDTH_USE_AUTO STRING "1"
|
| 54 |
+
// Retrieval info: PRIVATE: BANDWIDTH_USE_PRESET STRING "0"
|
| 55 |
+
// Retrieval info: PRIVATE: CLKBAD_SWITCHOVER_CHECK STRING "0"
|
| 56 |
+
// Retrieval info: PRIVATE: CLKLOSS_CHECK STRING "0"
|
| 57 |
+
// Retrieval info: PRIVATE: CLKSWITCH_CHECK STRING "0"
|
| 58 |
+
// Retrieval info: PRIVATE: CNX_NO_COMPENSATE_RADIO STRING "0"
|
| 59 |
+
// Retrieval info: PRIVATE: CREATE_CLKBAD_CHECK STRING "0"
|
| 60 |
+
// Retrieval info: PRIVATE: CREATE_INCLK1_CHECK STRING "0"
|
| 61 |
+
// Retrieval info: PRIVATE: CUR_DEDICATED_CLK STRING "c0"
|
| 62 |
+
// Retrieval info: PRIVATE: CUR_FBIN_CLK STRING "c0"
|
| 63 |
+
// Retrieval info: PRIVATE: DEVICE_SPEED_GRADE STRING "8"
|
| 64 |
+
// Retrieval info: PRIVATE: DIV_FACTOR0 NUMERIC "1"
|
| 65 |
+
// Retrieval info: PRIVATE: DUTY_CYCLE0 STRING "50.00000000"
|
| 66 |
+
// Retrieval info: PRIVATE: EFF_OUTPUT_FREQ_VALUE0 STRING "48.000000"
|
| 67 |
+
// Retrieval info: PRIVATE: EXPLICIT_SWITCHOVER_COUNTER STRING "0"
|
| 68 |
+
// Retrieval info: PRIVATE: EXT_FEEDBACK_RADIO STRING "0"
|
| 69 |
+
// Retrieval info: PRIVATE: GLOCKED_COUNTER_EDIT_CHANGED STRING "1"
|
| 70 |
+
// Retrieval info: PRIVATE: GLOCKED_FEATURE_ENABLED STRING "0"
|
| 71 |
+
// Retrieval info: PRIVATE: GLOCKED_MODE_CHECK STRING "0"
|
| 72 |
+
// Retrieval info: PRIVATE: GLOCK_COUNTER_EDIT NUMERIC "1048575"
|
| 73 |
+
// Retrieval info: PRIVATE: HAS_MANUAL_SWITCHOVER STRING "1"
|
| 74 |
+
// Retrieval info: PRIVATE: INCLK0_FREQ_EDIT STRING "27.000"
|
| 75 |
+
// Retrieval info: PRIVATE: INCLK0_FREQ_UNIT_COMBO STRING "MHz"
|
| 76 |
+
// Retrieval info: PRIVATE: INCLK1_FREQ_EDIT STRING "100.000"
|
| 77 |
+
// Retrieval info: PRIVATE: INCLK1_FREQ_EDIT_CHANGED STRING "1"
|
| 78 |
+
// Retrieval info: PRIVATE: INCLK1_FREQ_UNIT_CHANGED STRING "1"
|
| 79 |
+
// Retrieval info: PRIVATE: INCLK1_FREQ_UNIT_COMBO STRING "MHz"
|
| 80 |
+
// Retrieval info: PRIVATE: INTENDED_DEVICE_FAMILY STRING "Cyclone III"
|
| 81 |
+
// Retrieval info: PRIVATE: INT_FEEDBACK__MODE_RADIO STRING "1"
|
| 82 |
+
// Retrieval info: PRIVATE: LOCKED_OUTPUT_CHECK STRING "1"
|
| 83 |
+
// Retrieval info: PRIVATE: LONG_SCAN_RADIO STRING "1"
|
| 84 |
+
// Retrieval info: PRIVATE: LVDS_MODE_DATA_RATE STRING "Not Available"
|
| 85 |
+
// Retrieval info: PRIVATE: LVDS_MODE_DATA_RATE_DIRTY NUMERIC "0"
|
| 86 |
+
// Retrieval info: PRIVATE: LVDS_PHASE_SHIFT_UNIT0 STRING "deg"
|
| 87 |
+
// Retrieval info: PRIVATE: MIG_DEVICE_SPEED_GRADE STRING "Any"
|
| 88 |
+
// Retrieval info: PRIVATE: MIRROR_CLK0 STRING "0"
|
| 89 |
+
// Retrieval info: PRIVATE: MULT_FACTOR0 NUMERIC "1"
|
| 90 |
+
// Retrieval info: PRIVATE: NORMAL_MODE_RADIO STRING "1"
|
| 91 |
+
// Retrieval info: PRIVATE: OUTPUT_FREQ0 STRING "48.00000000"
|
| 92 |
+
// Retrieval info: PRIVATE: OUTPUT_FREQ_MODE0 STRING "1"
|
| 93 |
+
// Retrieval info: PRIVATE: OUTPUT_FREQ_UNIT0 STRING "MHz"
|
| 94 |
+
// Retrieval info: PRIVATE: PHASE_RECONFIG_FEATURE_ENABLED STRING "1"
|
| 95 |
+
// Retrieval info: PRIVATE: PHASE_RECONFIG_INPUTS_CHECK STRING "0"
|
| 96 |
+
// Retrieval info: PRIVATE: PHASE_SHIFT0 STRING "0.00000000"
|
| 97 |
+
// Retrieval info: PRIVATE: PHASE_SHIFT_STEP_ENABLED_CHECK STRING "0"
|
| 98 |
+
// Retrieval info: PRIVATE: PHASE_SHIFT_UNIT0 STRING "deg"
|
| 99 |
+
// Retrieval info: PRIVATE: PLL_ADVANCED_PARAM_CHECK STRING "0"
|
| 100 |
+
// Retrieval info: PRIVATE: PLL_ARESET_CHECK STRING "0"
|
| 101 |
+
// Retrieval info: PRIVATE: PLL_AUTOPLL_CHECK NUMERIC "1"
|
| 102 |
+
// Retrieval info: PRIVATE: PLL_ENHPLL_CHECK NUMERIC "0"
|
| 103 |
+
// Retrieval info: PRIVATE: PLL_FASTPLL_CHECK NUMERIC "0"
|
| 104 |
+
// Retrieval info: PRIVATE: PLL_FBMIMIC_CHECK STRING "0"
|
| 105 |
+
// Retrieval info: PRIVATE: PLL_LVDS_PLL_CHECK NUMERIC "0"
|
| 106 |
+
// Retrieval info: PRIVATE: PLL_PFDENA_CHECK STRING "0"
|
| 107 |
+
// Retrieval info: PRIVATE: PLL_TARGET_HARCOPY_CHECK NUMERIC "0"
|
| 108 |
+
// Retrieval info: PRIVATE: PRIMARY_CLK_COMBO STRING "inclk0"
|
| 109 |
+
// Retrieval info: PRIVATE: RECONFIG_FILE STRING "jtframe_pll6000.mif"
|
| 110 |
+
// Retrieval info: PRIVATE: SACN_INPUTS_CHECK STRING "0"
|
| 111 |
+
// Retrieval info: PRIVATE: SCAN_FEATURE_ENABLED STRING "1"
|
| 112 |
+
// Retrieval info: PRIVATE: SELF_RESET_LOCK_LOSS STRING "1"
|
| 113 |
+
// Retrieval info: PRIVATE: SHORT_SCAN_RADIO STRING "0"
|
| 114 |
+
// Retrieval info: PRIVATE: SPREAD_FEATURE_ENABLED STRING "0"
|
| 115 |
+
// Retrieval info: PRIVATE: SPREAD_FREQ STRING "50.000"
|
| 116 |
+
// Retrieval info: PRIVATE: SPREAD_FREQ_UNIT STRING "KHz"
|
| 117 |
+
// Retrieval info: PRIVATE: SPREAD_PERCENT STRING "0.500"
|
| 118 |
+
// Retrieval info: PRIVATE: SPREAD_USE STRING "0"
|
| 119 |
+
// Retrieval info: PRIVATE: SRC_SYNCH_COMP_RADIO STRING "0"
|
| 120 |
+
// Retrieval info: PRIVATE: STICKY_CLK0 STRING "1"
|
| 121 |
+
// Retrieval info: PRIVATE: SWITCHOVER_COUNT_EDIT NUMERIC "1"
|
| 122 |
+
// Retrieval info: PRIVATE: SWITCHOVER_FEATURE_ENABLED STRING "1"
|
| 123 |
+
// Retrieval info: PRIVATE: SYNTH_WRAPPER_GEN_POSTFIX STRING "0"
|
| 124 |
+
// Retrieval info: PRIVATE: USE_CLK0 STRING "1"
|
| 125 |
+
// Retrieval info: PRIVATE: USE_CLKENA0 STRING "0"
|
| 126 |
+
// Retrieval info: PRIVATE: USE_MIL_SPEED_GRADE NUMERIC "0"
|
| 127 |
+
// Retrieval info: PRIVATE: ZERO_DELAY_RADIO STRING "0"
|
| 128 |
+
// Retrieval info: LIBRARY: altera_mf altera_mf.altera_mf_components.all
|
| 129 |
+
// Retrieval info: CONSTANT: BANDWIDTH_TYPE STRING "AUTO"
|
| 130 |
+
// Retrieval info: CONSTANT: CLK0_DIVIDE_BY NUMERIC "9"
|
| 131 |
+
// Retrieval info: CONSTANT: CLK0_DUTY_CYCLE NUMERIC "50"
|
| 132 |
+
// Retrieval info: CONSTANT: CLK0_MULTIPLY_BY NUMERIC "16"
|
| 133 |
+
// Retrieval info: CONSTANT: CLK0_PHASE_SHIFT STRING "0"
|
| 134 |
+
// Retrieval info: CONSTANT: COMPENSATE_CLOCK STRING "CLK0"
|
| 135 |
+
// Retrieval info: CONSTANT: INCLK0_INPUT_FREQUENCY NUMERIC "37037"
|
| 136 |
+
// Retrieval info: CONSTANT: INTENDED_DEVICE_FAMILY STRING "Cyclone III"
|
| 137 |
+
// Retrieval info: CONSTANT: LPM_TYPE STRING "altpll"
|
| 138 |
+
// Retrieval info: CONSTANT: OPERATION_MODE STRING "NORMAL"
|
| 139 |
+
// Retrieval info: CONSTANT: PLL_TYPE STRING "AUTO"
|
| 140 |
+
// Retrieval info: CONSTANT: PORT_ACTIVECLOCK STRING "PORT_UNUSED"
|
| 141 |
+
// Retrieval info: CONSTANT: PORT_ARESET STRING "PORT_UNUSED"
|
| 142 |
+
// Retrieval info: CONSTANT: PORT_CLKBAD0 STRING "PORT_UNUSED"
|
| 143 |
+
// Retrieval info: CONSTANT: PORT_CLKBAD1 STRING "PORT_UNUSED"
|
| 144 |
+
// Retrieval info: CONSTANT: PORT_CLKLOSS STRING "PORT_UNUSED"
|
| 145 |
+
// Retrieval info: CONSTANT: PORT_CLKSWITCH STRING "PORT_UNUSED"
|
| 146 |
+
// Retrieval info: CONSTANT: PORT_CONFIGUPDATE STRING "PORT_UNUSED"
|
| 147 |
+
// Retrieval info: CONSTANT: PORT_FBIN STRING "PORT_UNUSED"
|
| 148 |
+
// Retrieval info: CONSTANT: PORT_INCLK0 STRING "PORT_USED"
|
| 149 |
+
// Retrieval info: CONSTANT: PORT_INCLK1 STRING "PORT_UNUSED"
|
| 150 |
+
// Retrieval info: CONSTANT: PORT_LOCKED STRING "PORT_USED"
|
| 151 |
+
// Retrieval info: CONSTANT: PORT_PFDENA STRING "PORT_UNUSED"
|
| 152 |
+
// Retrieval info: CONSTANT: PORT_PHASECOUNTERSELECT STRING "PORT_UNUSED"
|
| 153 |
+
// Retrieval info: CONSTANT: PORT_PHASEDONE STRING "PORT_UNUSED"
|
| 154 |
+
// Retrieval info: CONSTANT: PORT_PHASESTEP STRING "PORT_UNUSED"
|
| 155 |
+
// Retrieval info: CONSTANT: PORT_PHASEUPDOWN STRING "PORT_UNUSED"
|
| 156 |
+
// Retrieval info: CONSTANT: PORT_PLLENA STRING "PORT_UNUSED"
|
| 157 |
+
// Retrieval info: CONSTANT: PORT_SCANACLR STRING "PORT_UNUSED"
|
| 158 |
+
// Retrieval info: CONSTANT: PORT_SCANCLK STRING "PORT_UNUSED"
|
| 159 |
+
// Retrieval info: CONSTANT: PORT_SCANCLKENA STRING "PORT_UNUSED"
|
| 160 |
+
// Retrieval info: CONSTANT: PORT_SCANDATA STRING "PORT_UNUSED"
|
| 161 |
+
// Retrieval info: CONSTANT: PORT_SCANDATAOUT STRING "PORT_UNUSED"
|
| 162 |
+
// Retrieval info: CONSTANT: PORT_SCANDONE STRING "PORT_UNUSED"
|
| 163 |
+
// Retrieval info: CONSTANT: PORT_SCANREAD STRING "PORT_UNUSED"
|
| 164 |
+
// Retrieval info: CONSTANT: PORT_SCANWRITE STRING "PORT_UNUSED"
|
| 165 |
+
// Retrieval info: CONSTANT: PORT_clk0 STRING "PORT_USED"
|
| 166 |
+
// Retrieval info: CONSTANT: PORT_clk1 STRING "PORT_UNUSED"
|
| 167 |
+
// Retrieval info: CONSTANT: PORT_clk2 STRING "PORT_UNUSED"
|
| 168 |
+
// Retrieval info: CONSTANT: PORT_clk3 STRING "PORT_UNUSED"
|
| 169 |
+
// Retrieval info: CONSTANT: PORT_clk4 STRING "PORT_UNUSED"
|
| 170 |
+
// Retrieval info: CONSTANT: PORT_clk5 STRING "PORT_UNUSED"
|
| 171 |
+
// Retrieval info: CONSTANT: PORT_clkena0 STRING "PORT_UNUSED"
|
| 172 |
+
// Retrieval info: CONSTANT: PORT_clkena1 STRING "PORT_UNUSED"
|
| 173 |
+
// Retrieval info: CONSTANT: PORT_clkena2 STRING "PORT_UNUSED"
|
| 174 |
+
// Retrieval info: CONSTANT: PORT_clkena3 STRING "PORT_UNUSED"
|
| 175 |
+
// Retrieval info: CONSTANT: PORT_clkena4 STRING "PORT_UNUSED"
|
| 176 |
+
// Retrieval info: CONSTANT: PORT_clkena5 STRING "PORT_UNUSED"
|
| 177 |
+
// Retrieval info: CONSTANT: PORT_extclk0 STRING "PORT_UNUSED"
|
| 178 |
+
// Retrieval info: CONSTANT: PORT_extclk1 STRING "PORT_UNUSED"
|
| 179 |
+
// Retrieval info: CONSTANT: PORT_extclk2 STRING "PORT_UNUSED"
|
| 180 |
+
// Retrieval info: CONSTANT: PORT_extclk3 STRING "PORT_UNUSED"
|
| 181 |
+
// Retrieval info: CONSTANT: SELF_RESET_ON_LOSS_LOCK STRING "ON"
|
| 182 |
+
// Retrieval info: CONSTANT: WIDTH_CLOCK NUMERIC "5"
|
| 183 |
+
// Retrieval info: USED_PORT: @clk 0 0 5 0 OUTPUT_CLK_EXT VCC "@clk[4..0]"
|
| 184 |
+
// Retrieval info: USED_PORT: c0 0 0 0 0 OUTPUT_CLK_EXT VCC "c0"
|
| 185 |
+
// Retrieval info: USED_PORT: inclk0 0 0 0 0 INPUT_CLK_EXT GND "inclk0"
|
| 186 |
+
// Retrieval info: USED_PORT: locked 0 0 0 0 OUTPUT GND "locked"
|
| 187 |
+
// Retrieval info: CONNECT: @inclk 0 0 1 1 GND 0 0 0 0
|
| 188 |
+
// Retrieval info: CONNECT: @inclk 0 0 1 0 inclk0 0 0 0 0
|
| 189 |
+
// Retrieval info: CONNECT: c0 0 0 0 0 @clk 0 0 1 0
|
| 190 |
+
// Retrieval info: CONNECT: locked 0 0 0 0 @locked 0 0 0 0
|
| 191 |
+
// Retrieval info: GEN_FILE: TYPE_NORMAL jtframe_pll6000.v TRUE
|
| 192 |
+
// Retrieval info: GEN_FILE: TYPE_NORMAL jtframe_pll6000.ppf TRUE
|
| 193 |
+
// Retrieval info: GEN_FILE: TYPE_NORMAL jtframe_pll6000.inc FALSE
|
| 194 |
+
// Retrieval info: GEN_FILE: TYPE_NORMAL jtframe_pll6000.cmp FALSE
|
| 195 |
+
// Retrieval info: GEN_FILE: TYPE_NORMAL jtframe_pll6000.bsf FALSE
|
| 196 |
+
// Retrieval info: GEN_FILE: TYPE_NORMAL jtframe_pll6000_inst.v FALSE
|
| 197 |
+
// Retrieval info: GEN_FILE: TYPE_NORMAL jtframe_pll6000_bb.v TRUE
|
| 198 |
+
// Retrieval info: LIB_FILE: altera_mf
|
| 199 |
+
// Retrieval info: CBX_MODULE_PREFIX: ON
|
snapshots/jotego_jtcores_pr1270/modules/jtframe/target/mist/hdl/pll6000/jtframe_pll6144.qip
ADDED
|
File without changes
|
snapshots/jotego_jtcores_pr1270/modules/jtframe/target/mist/hdl/pll6000/jtframe_pll6293.qip
ADDED
|
File without changes
|
snapshots/jotego_jtcores_pr1270/modules/jtframe/target/mist/hdl/pll6000/jtframe_pll6671.qip
ADDED
|
File without changes
|
snapshots/jotego_jtcores_pr1270/modules/jtframe/target/mist/hdl/pll6000/jtframe_pllgame96.qip
ADDED
|
File without changes
|
snapshots/jotego_jtcores_pr1270/modules/jtframe/target/mist/hdl/pll6144/jtframe_pll6144.ppf
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?xml version="1.0" encoding="UTF-8" ?>
|
| 2 |
+
<!DOCTYPE pinplan>
|
| 3 |
+
<pinplan intended_family="Cyclone III" variation_name="jtframe_pll6144" megafunction_name="ALTPLL" specifies="all_ports">
|
| 4 |
+
<global>
|
| 5 |
+
<pin name="inclk0" direction="input" scope="external" source="clock" />
|
| 6 |
+
<pin name="c0" direction="output" scope="external" source="clock" />
|
| 7 |
+
<pin name="locked" direction="output" scope="external" />
|
| 8 |
+
|
| 9 |
+
</global>
|
| 10 |
+
</pinplan>
|
snapshots/jotego_jtcores_pr1270/modules/jtframe/target/mist/hdl/pll6144/jtframe_pll6144.qip
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
set_global_assignment -name IP_TOOL_NAME "ALTPLL"
|
| 2 |
+
set_global_assignment -name IP_TOOL_VERSION "13.1"
|
| 3 |
+
set_global_assignment -name VERILOG_FILE [file join $::quartus(qip_path) "jtframe_pll6144.v"]
|
| 4 |
+
set_global_assignment -name MISC_FILE [file join $::quartus(qip_path) "jtframe_pll6144_bb.v"]
|
| 5 |
+
set_global_assignment -name MISC_FILE [file join $::quartus(qip_path) "jtframe_pll6144.ppf"]
|