Git Product home page Git Product logo

cpu11's Introduction

Abstract

This CPU11 repository contains the results of historical PDP-11 microprocessors reverse engineering.

Typically the results include:

  • high-resolution photos of decapsulated crystals, both for top metal and diffusion layers
  • restored crystal topology in Sprint Layout 6.0 format, can be easily exported to Gerber
  • restored topology in PCAD format
  • restored gate-level schematics in PCAD and pdf formats
  • original asynchronous Verilog-HDL model of processor
  • refactored original Verilog-HDL model to synchronous one to run on real FPGA

There are a few words regarding the reverse engineering process stages:

  • sample decapsulating, milling die from the plastic package with CNC, then etching with 104 percents boiling oleum
  • serialized photographing of die with a motorized metallurgical microscope, hundreds of shots
  • shot stitching, getting the resulting high-resolution panoramic shot
  • removing the top metal layer with a polishing
  • getting the high-resolution panoramic shot of the diffusion layer
  • manual images vectorization - traces, vias, pads, etc.
  • gate recognition
  • transferring vectorized images to PCB CAD system
  • schematic restoration using PCB CAD back annotation
  • manual schematic refactoring into human-readable form
  • writing the original asynchronous Verilog HDL model, with all original schematics specifics
  • simulating and debug the original Verilog HDL model, running PDP-11 factory test software on the model
  • Verilog HDL model refactoring to get synchronous model, running on real FPGA
  • transforming processor-specific bus to standard Wishbone master interface to integrate into SoC

Processors

  • 1801BM1 - USSR microprocessor, no DEC prototype, proprietary die design
  • 1801BM2 - USSR microprocessor, no DEC prototype, proprietary die design
  • 1801BM3 - USSR microprocessor, no DEC prototype, proprietary die design
  • LSI-11 - Soviet 581-series, DEC LSI-11 clone, Western Digital MCP-1600 chipset
  • F-11 - Soviet 1811-series, DEC F-11 clone, DEC DC302/DC303/DC304 "Fonz" chipset
  • M4 - Soviet replica of military LSI-11M, AMD Am2900 bit-slices

PI-test performance

The 1000 signs of Pi calculation test is based on spigot algorithm. The digits are the times in 50Hz ticks. All models were Wishbone-compatible and run on the DE0 board with the same system configurations, software was placed into static memory with zero wait states and 4 minimal clocks per cycle (seems to be the bottleneck for the 1801BM3, it is capable to fetch ans execute reg-2-reg every 3 cycles). LSI-11 was running at 80MHz and results are multiplied by 0.8 to match with other ones. M4 was running at 50MHz and results are multiplied by 0.5. There are three variants of the test with various combinations of supported EIS instructions.

Model Frequency no EIS MUL only MUL/DIV cpm
LSI-11 100MHz(80MHz) 746 422 284 x1
F-11 100MHz 693 429 323 x2
1801BM1A 100MHz 586 --- --- x2
1801BM1Г 100MHz 588 458 --- x2
M4 100MHz(50MHz) 532 275 154 x1
1801BM3 100MHz 388 205 137 x1
1801BM2 100MHz 340 190 123 x2

Notes: "cpm" means core clocks per microinstruction, how many clocks model takes to execute single microcode instruction. For LSI-11 the four phases c1-c4 were refactored to the single core clock, for F-11 four phases were refactored to two core clocks. In addition the 1801ВМ2/1801BM3 performs the instruction prefetch gaining some boost.

Icarus Verilog

Icarus Verilog is an implementation of the Verilog hardware description language compiler that generates netlists in the desired format (EDIF). It supports the 1995, 2001 and 2005 versions of the Verilog standard, portions of SystemVerilog, and some extensions.

There are builds of Icarus Verilog for Windows available on site. We would recommend installing iverilog version 12. However version 10 should be sufficient as it comes as part of Ubuntu 20.04 LTS distribution.

There are run_iverilog.sh scripts added per each CPU model.

All scripts have similar structure:

  • run iverilog for specified top-level module and create *.vvp file
  • execute compiled representation by vvp command:

For example, LSI CPU has following script:

iverilog -c iverilog.cf -o tb_lsi.vvp -s tbl
vvp -n -v ./tb_lsi.vvp

The iverilog.cf file contains list of Verilog files to be added to desing (to be compiled and simulated).

Supported FPGA development boards

The synchronous models are planned to be run (and appropriate sample projects to be included in repo) on the following Development Kits:

cpu11's People

Contributors

1801bm1 avatar smaslovski avatar yshestakov avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

cpu11's Issues

VM3 mtpi in usermode not work.

This problem exists in real VM3 processors, but it may be possible to solve it in the verilog model. Which theoretically increases compatibility with DEC OS. These problems are mentioned in the DEMOS source codes.
https://github.com/sergev/vak-opensource/tree/master/bk/demos-dvk
DEMOS/src/sys/stand/bootstrap/M.s
94/05/13
/ Вставлены заглушки для дебильных процессоров ВМ3, в которых mtpi
/ не работает из-под пользовательского режима (mtpi, mfpi, clrseg).
...
/P3: Заменена на медленный аналог на C, работающий через mtpi().
/Это проще, чем переписывать, и не настолько уж медленно.
// clrseg(addr,count)
/.globl _clrseg
/_clrseg:
/ mov 4(sp),r0
/ beq 2f
/ asr r0
/ bic $!77777,r0
/ mov 2(sp),r1
/1:
/ clr -(sp)
/ mtpi (r1)+
/ sob r0,1b
/2:
/ rts pc

/ mtpd(word,addr)
.globl _mtpd
_mtpd:
cmp _cputype,$23. / ДВК, однако
beq mtpi_23
mov 4(sp),r0
mov 2(sp),-(sp)
mtpd (r0)+
rts pc

/ mtpi(word,addr)
.globl _mtpi
_mtpi:
cmp _cputype,$23.
beq mtpi_23
mov 4(sp),r0
mov 2(sp),-(sp)
mtpi (r0)+
rts pc

/P3: Вот mtpi(), которое не содержит mtpi.
/В оригинале есть побочный эффект: возвращается адрес+2. Не знаю, нужно
/ли это кому-нибудь. На всякий случай поддержано. Предполагается, что
/мы находимся где-то внизу адресного пространства программы и можем
/двигать сегмент #6.
mtpi_23:
mov 4(sp),r0 / addr
mov 2(sp),r1 / value
mov r2,-(sp)
mov r3,-(sp)

mov	r0,r2		/ Вычисляем индекс сегмента назначения
ash     $-12.,r2
bic     $177761,r2

mov	*$UISA6,r3	/ Спасаем и устанавливаем сегмент #6
mov	KISA0(r2),*$UISA6

mov	r0,r2		/ Относим смещение к базе #6
bic     $160000,r2
bis	$140000,r2

mov	r1,*r2

mov	r3,*$UISA6	/ Восстанавливаем базу #6

mov	(sp)+,r3
mov	(sp)+,r2
add	$2,r0
rts	pc

VM2 SEL274

When the VIRQ request does not acknowledge the interrupt vector, interrupts should occur at address SEL274, but the usual interrupt 004 occurs. Analysis of the problem showed that the reason is that the pli_ack signal is one clock cycle behind p[6] = acin & qbto & iako.
SEL274
It seems that this happened when switching to a synchronous processor model. This is not a problem at the DVK and UKNC, but it is critical for the work of the Souyz Neon.
I made a workaround by delaying the end of the wbi_stb_o signal by one clock cycle, but I’m not sure that this is the best solution.

+reg   old_wbi_stb_o;

always @(posedge vm_clk_p)
begin
+  old_wbi_stb_o <= wbi_stb_o;
-   vec_stb <= wbi_stb_o & ~wbi_una_o; 
+  vec_stb <= (wbi_stb_o | (old_wbi_stb_o & ~wbi_stb_o )) & ~wbi_una_o;

Minor syntax fix VM2 PREFETCH

I think we need to change blocking to non blocking statements.

-       bir_fix = (breg[14:12] != 3'o0)    // two ops instructions
+       bir_fix <= (breg[14:12] != 3'o0)    // two ops instructions

In these places:

pc2_res = (breg[14:12] != 3'o0) // two ops instructions

bir_fix = (breg[14:12] != 3'o0) // two ops instructions

bir_fix = (breg[14:12] != 3'o0) // two ops instructions

vm2: fix prefetch bug

It was reported the opcode prefetch bug is not completely fixed.

If VM2_CORE_FIX_PREFETCH is nonzero the PC2 prefetch bug fix is applied (not completely works, as it was found).

Original 1801BM2 processor contains microcode bug happening at the following conditions:
- two operands PDP-11 instruction is being executed
- source has addressing method @pc (field value 17 octal)
- destination does not involve PC (dst register field !=7)
- no extra instruction words are used by destination (no E(Rn),@e(Rn))
- Q-bus is slow and opcode prefetch is not completed before microcode
starts source field processing and fetching the source data (slow nRPLY/nAR)

VM2 FIS bug on User interrupt

The problem is the failure to update the “frozen” copy registers CPC and CPSW after the MTPS command, when the registers should be “unfrozen” and receive the current values of PC and PSW. The USER mode interrupts themselves are pushed onto the stack not by PC and PSW, but by CPC and CPSW. The FIS service is written in such a way that if it was called with interrupts enabled, then it should be executed in HALT mode with interrupts enabled. It starts in HALT mode with interrupts disabled, first saving all registers, CPC and CPSW. And then with the MTPS R0 command, it sets the same priority that was when calling the FIS command. An interrupt may occur immediately after this command. In the original 1801BM2, CPC and CPSW are immediately “unfrozen” and become equal to the current PC and PSW, respectively, they are already put on the stack. And in the FPGA version, after “defrosting” they do not have time to receive the current values of PC and PSW, and “frozen” values are put on the stack, i.e. PC and PSW after the FIS command.

Test code

000004/ 6
000006/ 0
000010/ 12
000012/ 0

000100/ 104
000102/ 200
000104/ 21627
000106/ 160000
000110/ 103402
000112/ 5237
000114/ 120
000116/ 2

001000/ 106427
001002/ 0
001004/ 5037
001006/ 120
001010/ 12706
001012/ 1000
001014/ 5046
001016/ 5046
001020/ 5046
001022/ 5046
001024/ 75006
001026/ 20627
001030/ 774
001032/ 1766
001034/ 0
001036/ 0

000760/ 0
000762/ 0
000764/ 0
000766/ 0
000770/ 0
000772/ 0
000774/ 0
000776/ 0

R0/ 0
R1/ 0
R2/ 0
R3/ 0
R4/ 0
R5/ 0
R6/ 1000
R7/ 1000

Fail result on FPGA BM2

1000G 001036
120/000002
760/177017
762/177015
764/001026
766/000004
770/000000
772/000000
774/000000
776/000000
R0/000004
R1/000000
R2/173044
R3/000000
R4/000000
R5/000000
R6/000770
R7/001036

000002 in address 000120 says that FIS was successfully interrupted twice after MTPS.
On the stack, address 000764 is 001024 and address 000766 is 4. These are the CPC and CPSW after the FADD SP command at address 001024.

It seems that this also happened when switching to a synchronous processor model.
And simple workaround for fix CPSW:

+always @(posedge vm_clk_n)
-always @(posedge vm_clk_p)
begin
   if (pswt_wa) psw[4] <= ax[4];
   if (psw_wa) psw[7:5] <= ax[7:5];
   if (psw8_wa) psw[8] <= ax[8];
end

+always @(posedge vm_clk_n)
-always @(posedge vm_clk_p)
begin
   if (psw_wa)
      psw[3:0] <= ax[3:0];
   else
   begin
      if (pswc_stb) psw[0] <= cond_c;
      if (psw_stb)  psw[1] <= cond_v;
      if (psw_stb)  psw[2] <= cond_z;
      if (psw_stb)  psw[3] <= cond_n;
   end
end

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.